use of net.dv8tion.jda.core.JDA in project Saber-Bot by notem.
the class VerifyUtilities method verifyAnnouncementAdd.
/**
* Returns error message (or empty string) for announcement add keyword verification
*/
public static String verifyAnnouncementAdd(String[] args, int index, String head, MessageReceivedEvent event) {
if (args.length - index < 3) {
return "That's not the right number of arguments for **" + args[index - 2] + " " + args[index - 1] + "**!\n" + "Use ``" + head + " " + args[0] + " " + args[index - 2] + " " + args[index - 1] + " [#target] [time] [message]``";
}
JDA jda = Main.getShardManager().getJDA(event.getGuild().getId());
String channelId = args[index].replaceAll("[^\\d]", "");
if (!channelId.matches("\\d+") || jda.getTextChannelById(channelId) == null) {
return "**" + args[index] + "** is not a channel on your server!";
}
if (!VerifyUtilities.verifyTimeString(args[index + 1])) {
return "**" + args[index + 1] + "** is not a properly formed announcement time!\n" + "Times use the format \"TYPE+/-OFFSET\". Ex: ``START+10m``, ``END-1h``";
}
return "";
}
use of net.dv8tion.jda.core.JDA in project Rubicon by Rubicon-Bot.
the class CommandAutochannel method execute.
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.getArgs();
Guild guild = parsedCommandInvocation.getMessage().getGuild();
JDA jda = RubiconBot.getJDA();
if (args.length == 1) {
if (args[0].equalsIgnoreCase("list")) {
String entry = RubiconBot.getMySQL().getGuildValue(guild, "autochannels");
StringBuilder out = new StringBuilder();
for (String s : entry.split(",")) {
out.append(jda.getVoiceChannelById(s).getName()).append("\n");
}
return new MessageBuilder().setEmbed(EmbedUtil.embed("Autochannels", out.toString()).setColor(Colors.COLOR_PRIMARY).build()).build();
} else
return createHelpMessage();
} else if (args.length >= 2) {
switch(args[0].toLowerCase()) {
case "create":
case "c":
createChannel(parsedCommandInvocation);
break;
case "del":
case "delete":
invokeDelete(parsedCommandInvocation);
break;
case "add":
case "set":
addChannel(parsedCommandInvocation);
break;
default:
return createHelpMessage();
}
} else
return createHelpMessage();
return null;
}
Aggregations