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_en.properties b/src/main/resources/Translations/Translations_en.properties
index 835004c..4d56039 100644
--- a/src/main/resources/Translations/Translations_en.properties
+++ b/src/main/resources/Translations/Translations_en.properties
@@ -100,6 +100,8 @@ 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