Started game role commands
This commit is contained in:
parent
d50e9a23ce
commit
519e0f468e
2 changed files with 46 additions and 1 deletions
|
@ -10,7 +10,7 @@ public abstract class DiscordCommandBase {
|
||||||
public abstract String getCommandName();
|
public abstract String getCommandName();
|
||||||
|
|
||||||
public abstract void run(IMessage message, String args);
|
public abstract void run(IMessage message, String args);
|
||||||
|
|
||||||
public abstract String[] getHelpText();
|
public abstract String[] getHelpText();
|
||||||
|
|
||||||
static final HashMap<String, DiscordCommandBase> commands = new HashMap<String, DiscordCommandBase>();
|
static final HashMap<String, DiscordCommandBase> commands = new HashMap<String, DiscordCommandBase>();
|
||||||
|
@ -19,6 +19,7 @@ public abstract class DiscordCommandBase {
|
||||||
commands.put("connect", new ConnectCommand()); // TODO: API for adding commands?
|
commands.put("connect", new ConnectCommand()); // TODO: API for adding commands?
|
||||||
commands.put("userinfo", new UserinfoCommand());
|
commands.put("userinfo", new UserinfoCommand());
|
||||||
commands.put("help", new HelpCommand());
|
commands.put("help", new HelpCommand());
|
||||||
|
commands.put("role", new RoleCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runCommand(String cmd, String args, IMessage message) {
|
public static void runCommand(String cmd, String args, IMessage message) {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package buttondevteam.discordplugin.commands;
|
||||||
|
|
||||||
|
import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
|
import sx.blah.discord.handle.obj.IMessage;
|
||||||
|
|
||||||
|
public class RoleCommand extends DiscordCommandBase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return "role";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(IMessage message, String args) {
|
||||||
|
final String usagemsg = "Subcommands: add, remove, list";
|
||||||
|
if (args.length() == 0) {
|
||||||
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), usagemsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] argsa = args.split(" ");
|
||||||
|
if (argsa[0].equalsIgnoreCase("add")) {
|
||||||
|
if (argsa.length < 2) {
|
||||||
|
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||||
|
"This command adds a game role to your account.\nUsage: add <rolename>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (argsa[0].equalsIgnoreCase("remove")) {
|
||||||
|
if (argsa.length < 2) {
|
||||||
|
DiscordPlugin.sendMessageToChannel(message.getChannel(),
|
||||||
|
"This command removes a game role from your account.\nUsage: remove <rolename>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (argsa[0].equalsIgnoreCase("list")) {
|
||||||
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), "List of game roles:");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getHelpText() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue