diff --git a/pom.xml b/pom.xml index 0460e6c..787cd26 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ net.dv8tion JDA - 4.1.1_127 + 4.1.1_131 org.json @@ -91,12 +91,12 @@ org.kohsuke github-api - 1.108 + 1.109 com.sedmelluq lavaplayer - 1.3.40 + 1.3.44 com.fasterxml.jackson.core diff --git a/src/main/java/com/bbn/hadder/Rethink.java b/src/main/java/com/bbn/hadder/Rethink.java index 6be8bdd..5f8ee59 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -22,6 +22,7 @@ import com.rethinkdb.gen.exc.ReqlNonExistenceError; import com.rethinkdb.gen.exc.ReqlOpFailedError; import com.rethinkdb.net.Connection; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import java.lang.reflect.Field; @@ -78,7 +79,12 @@ public class Rethink { public JSONObject getObjectByID(String table, String id) { String response = r.table(table).get(id).toJson().run(conn); - return new JSONObject(response); + try { + return new JSONObject(response); + } catch (JSONException e) { + System.out.println(response); + return null; + } } public void insert(String table, Object object) { diff --git a/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java index a154bb2..9f22e89 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java @@ -31,7 +31,7 @@ public class CodeCommand implements Command { public void executed(String[] args, CommandEvent e) { if (args.length > 0) { OkHttpClient client = new OkHttpClient(); - Request request = new Request.Builder().url("https://canary.discordapp.com/api/v6/invite/" + args[0]).addHeader("Authorization", "Bot " + e.getConfig().getBotToken()).build(); + Request request = new Request.Builder().url("https://canary.discordapp.com/api/v6/invite/" + args[0] + "?with_counts=true").addHeader("Authorization", "Bot " + e.getConfig().getBotToken()).build(); try { Response response = client.newCall(request).execute(); @@ -45,6 +45,9 @@ public class CodeCommand implements Command { .addField("Verification Level", String.valueOf(json.getJSONObject("guild").getInt("verification_level")), true) .addField("Guild ID", json.getJSONObject("guild").getString("id"), true) .addBlankField(true) + .addField("Members", String.valueOf(json.get("approximate_member_count")), true) + .addBlankField(true) + .addBlankField(true) .setThumbnail("https://cdn.discordapp.com/icons/" + json.getJSONObject("guild").getString("id") + "/" + json.getJSONObject("guild").getString("icon") + ".png") .build()).queue(); } catch (JSONException ex) { 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 b8d1dc6..3dbf7c0 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/MoveAllCommand.java @@ -30,14 +30,21 @@ public class MoveAllCommand implements Command { if (args.length == 2) { 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(); + if (!args[0].equals(args[1])) { + 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.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.misc.moveall.error.equals.title", + "commands.misc.moveall.error.equals.description") + .build()).queue(); + } } else { e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.moveall.error.target.int.title", diff --git a/src/main/resources/Translations/Translations_de.properties b/src/main/resources/Translations/Translations_de.properties index 2be75d8..8d5f954 100644 --- a/src/main/resources/Translations/Translations_de.properties +++ b/src/main/resources/Translations/Translations_de.properties @@ -97,15 +97,11 @@ commands.misc.code.success.title = Informationen zum Einladungscode commands.misc.code.success.description = Diese Nachricht enthält einige Informationen über den angegebenen Einladungscode. commands.misc.code.error.title = Code nicht gefunden commands.misc.code.error.description = Ich kann den angegebenen Einladungscode nicht finden. -commands.misc.code.help.description = Zeigt Informationen über einen Einladungs-Code. -commands.misc.moveall.success.title = Erfolgreich verschoben +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 = Ungültige 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 = Ungültige 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 = Zeigt die neuesten Statistiken von COVID-19 +commands.misc.corona.help.description = Show the newest stats about COVID-19 commands.moderation.ban.success.title = Erfolgreich gebannt commands.moderation.ban.success.description = Ich habe %extra% erfolgreich gebannt @@ -274,7 +270,7 @@ commands.music.volume.help.description = Ändere die Lautstärke der Musik. commands.music.pause.success.title = Erfolgreich pausiert commands.music.pause.success.description = Ich habe den gespielten Song erfolgreich pausiert. commands.music.pause.error.paused.title = Bereits pausiert -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = Das Lied ist bereits pausiert. commands.music.pause.error.connected.title = Kein Kanal commands.music.pause.error.connected.description = Du musst im selben Sprachkanal wie der Bot sein, um den Song zu pausieren. commands.music.pause.help.description = Pausiere das abgespielte Lied. @@ -320,7 +316,7 @@ commands.owner.guildleave.help.description = Quit from a server commands.owner.reboot.help.description = Startet den Bot neu. commands.owner.shutdown.success.title = Fährt herrunter commands.owner.shutdown.help.description = Schalte den Bot ab. -commands.owner.test.success = Meine Freunde testen +commands.owner.test.success = TEST my friends commands.owner.test.help.description = Nur ein kleiner Testbefehl commands.owner.blacklist.success.add.title = Successfully blacklisted the specified commands commands.owner.blacklist.success.add.description = I successfully added the following commands from the blacklist\:\n %extra% diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 835004c..4ae304a 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -100,12 +100,14 @@ 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.equals.title = Not twice +commands.misc.moveall.error.equals.description = The first voice channel equals the second. You have to specify two different voice channels. 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 = Shows the newest stats of COVID-19 +commands.misc.corona.help.description = Show the newest stats about COVID-19 commands.moderation.ban.success.title = Successfully banned commands.moderation.ban.success.description = I successfully baned %extra% diff --git a/src/main/resources/Translations/Translations_es.properties b/src/main/resources/Translations/Translations_es.properties index 98b2a88..1f07242 100644 --- a/src/main/resources/Translations/Translations_es.properties +++ b/src/main/resources/Translations/Translations_es.properties @@ -100,10 +100,6 @@ 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 @@ -274,7 +270,7 @@ commands.music.volume.help.description = Change the volume of the music. commands.music.pause.success.title = Successfully paused commands.music.pause.success.description = I successfully paused the played song. commands.music.pause.error.paused.title = Already paused -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = The song is already paused. commands.music.pause.error.connected.title = No channel commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song. commands.music.pause.help.description = Pause the playing song. diff --git a/src/main/resources/Translations/Translations_fr.properties b/src/main/resources/Translations/Translations_fr.properties index 98b2a88..1f07242 100644 --- a/src/main/resources/Translations/Translations_fr.properties +++ b/src/main/resources/Translations/Translations_fr.properties @@ -100,10 +100,6 @@ 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 @@ -274,7 +270,7 @@ commands.music.volume.help.description = Change the volume of the music. commands.music.pause.success.title = Successfully paused commands.music.pause.success.description = I successfully paused the played song. commands.music.pause.error.paused.title = Already paused -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = The song is already paused. commands.music.pause.error.connected.title = No channel commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song. commands.music.pause.help.description = Pause the playing song. diff --git a/src/main/resources/Translations/Translations_ru.properties b/src/main/resources/Translations/Translations_ru.properties index 98b2a88..1f07242 100644 --- a/src/main/resources/Translations/Translations_ru.properties +++ b/src/main/resources/Translations/Translations_ru.properties @@ -100,10 +100,6 @@ 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 @@ -274,7 +270,7 @@ commands.music.volume.help.description = Change the volume of the music. commands.music.pause.success.title = Successfully paused commands.music.pause.success.description = I successfully paused the played song. commands.music.pause.error.paused.title = Already paused -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = The song is already paused. commands.music.pause.error.connected.title = No channel commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song. commands.music.pause.help.description = Pause the playing song. diff --git a/src/main/resources/Translations/Translations_tr.properties b/src/main/resources/Translations/Translations_tr.properties index 98b2a88..1f07242 100644 --- a/src/main/resources/Translations/Translations_tr.properties +++ b/src/main/resources/Translations/Translations_tr.properties @@ -100,10 +100,6 @@ 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 @@ -274,7 +270,7 @@ commands.music.volume.help.description = Change the volume of the music. commands.music.pause.success.title = Successfully paused commands.music.pause.success.description = I successfully paused the played song. commands.music.pause.error.paused.title = Already paused -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = The song is already paused. commands.music.pause.error.connected.title = No channel commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song. commands.music.pause.help.description = Pause the playing song. diff --git a/src/main/resources/Translations/Translations_zh.properties b/src/main/resources/Translations/Translations_zh.properties index 98b2a88..1f07242 100644 --- a/src/main/resources/Translations/Translations_zh.properties +++ b/src/main/resources/Translations/Translations_zh.properties @@ -100,10 +100,6 @@ 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 @@ -274,7 +270,7 @@ commands.music.volume.help.description = Change the volume of the music. commands.music.pause.success.title = Successfully paused commands.music.pause.success.description = I successfully paused the played song. commands.music.pause.error.paused.title = Already paused -commands.music.pause.error.paused.description = The song is already paused. You can continue playing it with %extra%play +commands.music.pause.error.paused.description = The song is already paused. commands.music.pause.error.connected.title = No channel commands.music.pause.error.connected.description = You have to be in the same voice channel as the bot to pause the song. commands.music.pause.help.description = Pause the playing song.