Added default command for fallback catching
This commit is contained in:
parent
0f1316aa30
commit
d1dd1fe758
@ -0,0 +1,29 @@
|
|||||||
|
package dev.salmonllama.fsbot.commands.developer;
|
||||||
|
|
||||||
|
import dev.salmonllama.fsbot.guthix.Command;
|
||||||
|
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||||
|
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||||
|
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||||
|
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class DefaultCommand extends Command {
|
||||||
|
@Override public String name() { return "Default"; }
|
||||||
|
@Override public String description() { return "The command that gets invoked when the prefix is used, but the command is not recognized"; }
|
||||||
|
@Override public String usage() { return "you don't use this command"; }
|
||||||
|
@Override public String category() { return "Invisible"; }
|
||||||
|
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.OWNER); }
|
||||||
|
@Override public Collection<String> aliases() { return Collections.singletonList("default"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommand(CommandContext ctx) {
|
||||||
|
EmbedBuilder response = new EmbedBuilder()
|
||||||
|
.setTitle("Oops!")
|
||||||
|
.setAuthor(ctx.getApi().getYourself())
|
||||||
|
.setDescription("That's my prefix, but I don't know that command! Try using `~help` to see what I can do!");
|
||||||
|
|
||||||
|
ctx.reply(response);
|
||||||
|
}
|
||||||
|
}
|
@ -101,15 +101,15 @@ public class Guthix implements MessageCreateListener {
|
|||||||
RegistryCommand rComm = registry.getCommandInfo(content);
|
RegistryCommand rComm = registry.getCommandInfo(content);
|
||||||
String cmdString = rComm.getCommand().toLowerCase();
|
String cmdString = rComm.getCommand().toLowerCase();
|
||||||
|
|
||||||
if (registry.isCommandAlias(cmdString)) {
|
// if (registry.isCommandAlias(cmdString)) {
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
String[] cmdArgs = rComm.getArgs();
|
String[] cmdArgs = rComm.getArgs();
|
||||||
|
|
||||||
Command cmd = registry.findCommand(cmdString).orElse(null); // TODO: default command here
|
Command cmd = registry.findCommand(cmdString).orElse(new DefaultCommand()); // TODO: default command here
|
||||||
|
|
||||||
CommandContext ctx = new CommandContext.CommandContextBuilder(
|
CommandContext ctx = new CommandContext.CommandContextBuilder(
|
||||||
event,
|
event,
|
||||||
|
Loading…
Reference in New Issue
Block a user