diff --git a/pom.xml b/pom.xml index 8fc48d9..5870d56 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Hadder Hadder - 1.1.3 + 1.3.1 Hadder 2019 Hadder is a multi-purpose Discord bot. @@ -66,7 +66,7 @@ net.dv8tion JDA - 4.1.1_113 + 4.1.1_122 org.json diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index 99f9b3d..4afe7ca 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -51,15 +51,14 @@ public class Hadder { Rethink rethink = new Rethink(config); rethink.connect(); - DefaultShardManagerBuilder builder = new DefaultShardManagerBuilder(); + DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.createDefault(config.getBotToken()); builder.setAutoReconnect(true); builder.setShardsTotal(1); - builder.setChunkingFilter(ChunkingFilter.ALL); + builder.setChunkingFilter(ChunkingFilter.NONE); builder.setBulkDeleteSplittingEnabled(true); builder.setActivity(Activity.listening("to h.help")); builder.setStatus(OnlineStatus.DO_NOT_DISTURB); - builder.setToken(config.getBotToken()); HelpCommand helpCommand = new HelpCommand(); AudioManager audioManager = new AudioManager(); diff --git a/src/main/java/com/bbn/hadder/Rethink.java b/src/main/java/com/bbn/hadder/Rethink.java index aeaaf58..6be8bdd 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -72,8 +72,8 @@ public class Rethink { else return null; } - public Object getByID(String table, String wherevalue, String column) { - return r.table(table).get(wherevalue).getField(column).run(conn); + public Object getByID(String table, String where, String column) { + return r.table(table).get(where).getField(column).run(conn); } public JSONObject getObjectByID(String table, String id) { diff --git a/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java b/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java index 519e681..b8d1dc6 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java @@ -20,6 +20,7 @@ import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.core.Perm; import com.bbn.hadder.core.Perms; import com.bbn.hadder.utils.MessageEditor; +import org.apache.commons.lang3.StringUtils; @Perms(Perm.VOICE_MOVE_OTHERS) public class MoveAllCommand implements Command { @@ -27,14 +28,26 @@ public class MoveAllCommand implements Command { @Override public void executed(String[] args, CommandEvent e) { if (args.length == 2) { - int count = e.getGuild().getVoiceChannelById(args[0]).getMembers().size(); - e.getGuild().getVoiceChannelById(args[0]).getMembers().forEach( - member -> e.getGuild().moveVoiceMember(member, e.getGuild().getVoiceChannelById(args[1])).queue() - ); - e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, - "commands.misc.moveall.success.title", "", - "commands.misc.moveall.success.description", String.valueOf(count)) - .build()).queue(); + if (StringUtils.isNumeric(args[0]) && args[0].length() == 18) { + if (StringUtils.isNumeric(args[1]) && args[1].length() == 18) { + int count = e.getGuild().getVoiceChannelById(args[0]).getMembers().size(); + e.getGuild().getVoiceChannelById(args[0]).getMembers().forEach( + member -> e.getGuild().moveVoiceMember(member, e.getGuild().getVoiceChannelById(args[1])).queue() + ); + e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, + "commands.misc.moveall.success.title", "", + "commands.misc.moveall.success.description", String.valueOf(count)) + .build()).queue(); + } else { + e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.misc.moveall.error.target.int.title", + "commands.misc.moveall.error.target.int.description").build()).queue(); + } + } else { + e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.misc.moveall.error.source.int.title", + "commands.misc.moveall.error.source.int.description").build()).queue(); + } } else e.getHelpCommand().sendHelp(this, e); } diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 1f07242..54ef718 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -100,6 +100,10 @@ commands.misc.code.error.description = I can't find the specified invite code. commands.misc.code.help.description = Shows information about a invite code. commands.misc.moveall.success.title = Successfully moved commands.misc.moveall.success.description = I successfully moved %extra% members. Have fun\! +commands.misc.moveall.error.source.int.title = Invalid ID +commands.misc.moveall.error.source.int.description = You didn't specified a ID as the source channel. +commands.misc.moveall.error.target.int.title = Invalid ID +commands.misc.moveall.error.target.int.description = You didn't specified a ID as the target channel. commands.misc.moveall.help.description = Moves all users in the source channel to the target channel. commands.misc.corona.help.description = Show the newest stats about COVID-19