Started game role commands

This commit is contained in:
Norbi Peti 2017-01-14 01:33:44 +01:00
parent d50e9a23ce
commit 519e0f468e
2 changed files with 46 additions and 1 deletions

View file

@ -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) {

View file

@ -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;
}
}