From 4bdbb6e0b957e5627f0bfb7b7992bf9ae51f44ef Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Mon, 3 Feb 2020 11:54:31 +0100 Subject: [PATCH 1/9] Fix #365 --- src/main/java/com/bbn/hadder/listener/MentionListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/bbn/hadder/listener/MentionListener.java b/src/main/java/com/bbn/hadder/listener/MentionListener.java index 1e637b5..276a02f 100644 --- a/src/main/java/com/bbn/hadder/listener/MentionListener.java +++ b/src/main/java/com/bbn/hadder/listener/MentionListener.java @@ -28,7 +28,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import javax.annotation.Nonnull; -import java.io.FileReader; import java.io.IOException; import java.util.Random; @@ -51,7 +50,7 @@ public class MentionListener extends ListenerAdapter { MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = null; try { - model = reader.read(new FileReader("pom.xml")); + model = reader.read(this.getClass().getClassLoader().getResourceAsStream("pom.xml")); } catch (IOException | XmlPullParserException ex) { ex.printStackTrace(); } From 79d5d67b5530d8118463a0d8d10746663d35492b Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Mon, 3 Feb 2020 22:07:21 +0100 Subject: [PATCH 2/9] Update version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87e9493..8060f47 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Hadder Hadder - 1.0.1 + 1.0.2 Hadder From 214b84d0c52362707663aa43fe9a4e8a7f75f8f9 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Tue, 4 Feb 2020 15:01:16 +0100 Subject: [PATCH 3/9] Remove unused disconnect --- src/main/java/com/bbn/hadder/Rethink.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/bbn/hadder/Rethink.java b/src/main/java/com/bbn/hadder/Rethink.java index a714fd2..6bc066c 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -51,11 +51,6 @@ public class Rethink { } } - public void disconnect() { - conn.close(); - System.out.println("DISCONNECTED"); - } - private JSONArray getAsArray(String table, String where, String value) { try { String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn); From eabaf6dd5cf99275757c7a5b1dd1dffb7e97cc3a Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Tue, 4 Feb 2020 15:01:36 +0100 Subject: [PATCH 4/9] Add features to serverstats --- .../java/com/bbn/hadder/commands/misc/ServerStatsCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/bbn/hadder/commands/misc/ServerStatsCommand.java b/src/main/java/com/bbn/hadder/commands/misc/ServerStatsCommand.java index 788701c..6ea8bbf 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/ServerStatsCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/ServerStatsCommand.java @@ -42,7 +42,7 @@ public class ServerStatsCommand implements Command { .addField("MFA Level", String.valueOf(e.getGuild().getRequiredMFALevel().getKey()), true) .addField("Member Count", String.valueOf(e.getGuild().getMemberCount()), true) .addField("Explicit Content Level", e.getGuild().getExplicitContentLevel().getKey() + ": " + e.getGuild().getExplicitContentLevel(), true) - //TODO: Features + .addField("Features", e.getGuild().getFeatures().toString().replaceAll("\\[", "`").replaceAll(",", "`, `").replaceAll("]", "`"), true) .setThumbnail(e.getGuild().getIconUrl()) .setImage(e.getGuild().getBannerUrl()); From db436aeb7f00d320c637bf43075303ee5a1b79db Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 5 Feb 2020 01:13:40 +0100 Subject: [PATCH 5/9] whitehouse.gov/sotu --- src/main/java/com/bbn/hadder/Hadder.java | 3 +- .../bbn/hadder/commands/misc/CodeCommand.java | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index 8db6557..57a7cb0 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -125,7 +125,8 @@ public class Hadder { new BassCommand(), new EchoCommand(), new ServerStatsCommand(), - new ProfileCommand()), config, helpCommand); + new ProfileCommand(), + new CodeCommand()), config, helpCommand); builder.addEventListeners( new MentionListener(rethink), diff --git a/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java new file mode 100644 index 0000000..5f8b5d2 --- /dev/null +++ b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019-2020 GregTCLTK and Schlauer-Hax + * + * Licensed under the GNU Affero General Public License, Version 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/agpl-3.0.en.html + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bbn.hadder.commands.misc; + +import com.bbn.hadder.commands.Command; +import com.bbn.hadder.commands.CommandEvent; + +public class CodeCommand implements Command { + + @Override + public void executed(String[] args, CommandEvent e) { + if (args.length > 0) { + + } else e.getHelpCommand().sendHelp(this, e); + } + + @Override + public String[] labels() { + return new String[]{"code", "invite-code", "ic"}; + } + + @Override + public String description() { + return "Shows information about a invite code,."; + } + + @Override + public String usage() { + return "[Invite-code]"; + } + + @Override + public String example() { + return "58My2dM"; + } +} From 2e2614b9517c53d3925fffcccefe03e0c86e34e1 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 5 Feb 2020 01:27:05 +0100 Subject: [PATCH 6/9] Add i18n --- src/main/resources/Translations/Translations_en.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 2f19d7d..111235e 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -93,6 +93,9 @@ commands.misc.serverstats.help.description = Shows information about a server. commands.misc.profile.error.title = Not found commands.misc.profile.error.description = I can't find the specified user. commands.misc.profile.help.description = Shows some information about the specified user. +commands.misc.code.error.title = Code not found +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.moderation.ban.success.title = Successfully banned commands.moderation.ban.success.description = I successfully baned %extra% From 14166c1e35616bb1d77da05462e985a0e37179a7 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 5 Feb 2020 01:29:53 +0100 Subject: [PATCH 7/9] More i18n --- src/main/resources/Translations/Translations_en.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 111235e..75aaadd 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -93,6 +93,8 @@ commands.misc.serverstats.help.description = Shows information about a server. commands.misc.profile.error.title = Not found commands.misc.profile.error.description = I can't find the specified user. commands.misc.profile.help.description = Shows some information about the specified user. +commands.misc.code.success.title = Invite code information +commands.misc.code.success.description = This message contains some information about the specified invite code. commands.misc.code.error.title = Code not found commands.misc.code.error.description = I can't find the specified invite code. commands.misc.code.help.description = Shows information about a invite code. From 62adda7083484a7ee3aa97fec9c0e33934466a4a Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 5 Feb 2020 01:30:05 +0100 Subject: [PATCH 8/9] The real command --- .../bbn/hadder/commands/misc/CodeCommand.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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 5f8b5d2..b944bb6 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java @@ -18,13 +18,38 @@ package com.bbn.hadder.commands.misc; import com.bbn.hadder.commands.Command; import com.bbn.hadder.commands.CommandEvent; +import com.bbn.hadder.utils.MessageEditor; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.json.JSONException; +import org.json.JSONObject; public class CodeCommand implements Command { @Override 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(); + + try { + Response response = client.newCall(request).execute(); + JSONObject json = new JSONObject(response.body().string()); + e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, + "commands.misc.code.success.title", + "commands.misc.code.success.description") + .addField("Code", "[" + args[0] + "](https://discord.gg/" + args[0] + ")", true) + .addField("Guild Name", json.getJSONObject("guild").getString("name"), true) + .build()).queue(); + e.getTextChannel().sendMessage(json.toString()).queue(); + } catch (JSONException ex) { + e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.misc.code.error.title", + "commands.misc.code.error.description").build()).queue(); + } catch (Exception ex) { + ex.printStackTrace(); + } } else e.getHelpCommand().sendHelp(this, e); } @@ -35,7 +60,7 @@ public class CodeCommand implements Command { @Override public String description() { - return "Shows information about a invite code,."; + return "commands.misc.code.help.description"; } @Override From c08d5290b919093445f4fdaebdaff6d4ac7ed8b6 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 5 Feb 2020 01:40:12 +0100 Subject: [PATCH 9/9] Add extra fields --- src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java | 3 +++ 1 file changed, 3 insertions(+) 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 b944bb6..728a975 100644 --- a/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java +++ b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java @@ -41,6 +41,9 @@ public class CodeCommand implements Command { "commands.misc.code.success.description") .addField("Code", "[" + args[0] + "](https://discord.gg/" + args[0] + ")", true) .addField("Guild Name", json.getJSONObject("guild").getString("name"), true) + .addField("Guild ID", json.getJSONObject("guild").getString("id"), true) + .addField("Verification Level", json.getJSONObject("guild").getString("verification_level"), true) + .setThumbnail("https://cdn.discordapp.com/icons/" + json.getJSONObject("guild").getString("id") + "/" + json.getJSONObject("guild").getString("icon") + ".png") .build()).queue(); e.getTextChannel().sendMessage(json.toString()).queue(); } catch (JSONException ex) {