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
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/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);
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..728a975
--- /dev/null
+++ b/src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java
@@ -0,0 +1,78 @@
+/*
+ * 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;
+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)
+ .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) {
+ 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);
+ }
+
+ @Override
+ public String[] labels() {
+ return new String[]{"code", "invite-code", "ic"};
+ }
+
+ @Override
+ public String description() {
+ return "commands.misc.code.help.description";
+ }
+
+ @Override
+ public String usage() {
+ return "[Invite-code]";
+ }
+
+ @Override
+ public String example() {
+ return "58My2dM";
+ }
+}
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());
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();
}
diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties
index 2f19d7d..75aaadd 100644
--- a/src/main/resources/Translations/Translations_en.properties
+++ b/src/main/resources/Translations/Translations_en.properties
@@ -93,6 +93,11 @@ 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.
commands.moderation.ban.success.title = Successfully banned
commands.moderation.ban.success.description = I successfully baned %extra%