diff --git a/README.md b/README.md index db85607..67adf75 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,9 @@ Hadder Discord is a multi-purpose Discord bot with 100% uptime. [![GitHub license](https://img.shields.io/github/license/BigBotNetwork/Hadder)](https://github.com/BigBotNetwork/Hadder/blob/master/LICENSE) [![time tracker](https://wakatime.com/badge/github/BigBotNetwork/Hadder.svg)](https://wakatime.com/badge/github/BigBotNetwork/Hadder) -[![MBL](Https://Mythicalbots.Xyz/Bot/637002314162372639/Embed?Q=Dark/ )](Https://Mythicalbots.Xyz/Bot/637002314162372639) +[![Discord Extreme List](https://api.discordextremelist.xyz/v1/bot/637002314162372639/widget)](https://discordextremelist.xyz/bots/Hadder) [![Discord Bots](https://top.gg/api/widget/637002314162372639.svg)](https://top.gg/bot/637002314162372639) [![Hadder's Widget](https://api.botlist.space/widget/637002314162372639/2 "Hadder's Widget")](https://botlist.space/bot/637002314162372639?utm_source=bls&utm_medium=widget&utm_campaign=637002314162372639) -[![Discord Bots](https://discordbotlist.com/bots/637002314162372639/widget)](https://discordbotlist.com/bots/637002314162372639) ## Hadder Team ### Developer diff --git a/pom.xml b/pom.xml index 7548e0f..8060f47 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Hadder Hadder - 1.0.3 + 1.0.2 Hadder @@ -56,7 +56,7 @@ net.dv8tion JDA - 4.1.1_108 + 4.1.1_105 org.json diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index b13870c..57a7cb0 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -126,8 +126,7 @@ public class Hadder { new EchoCommand(), new ServerStatsCommand(), new ProfileCommand(), - new CodeCommand(), - new RoleAssignmentCommand()), config, helpCommand); + 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 29b8346..6bc066c 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -18,7 +18,6 @@ package com.bbn.hadder; import com.bbn.hadder.core.Config; import com.rethinkdb.RethinkDB; -import com.rethinkdb.gen.exc.ReqlNonExistenceError; import com.rethinkdb.gen.exc.ReqlOpFailedError; import com.rethinkdb.net.Connection; import org.json.JSONArray; @@ -27,6 +26,7 @@ import org.json.JSONObject; import java.lang.reflect.Field; import java.util.NoSuchElementException; + public class Rethink { private RethinkDB r = RethinkDB.r; private Connection conn; @@ -154,12 +154,7 @@ public class Rethink { } // TODO public boolean hasStarboardMessage(String message_id) { - try { - this.getByID("stars", message_id, "guild"); - return true; - } catch (ReqlNonExistenceError e) { - return false; - } + return this.getByID("stars", message_id, "guild") != null; } @@ -190,4 +185,5 @@ public class Rethink { } r.table("user").get(user.getId()).update(object.toMap()).run(conn); } + } diff --git a/src/main/java/com/bbn/hadder/commands/moderation/RoleAssignmentCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/RoleAssignmentCommand.java deleted file mode 100644 index 9259b43..0000000 --- a/src/main/java/com/bbn/hadder/commands/moderation/RoleAssignmentCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.moderation; - -import com.bbn.hadder.commands.Command; -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 net.dv8tion.jda.api.Permission; - -@Perms(Perm.MANAGE_ROLES) -public class RoleAssignmentCommand implements Command { - - @Override - public void executed(String[] args, CommandEvent e) { - if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) { - - } else e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue(); - } - - @Override - public String[] labels() { - return new String[0]; - } - - @Override - public String description() { - return null; - } - - @Override - public String usage() { - return null; - } - - @Override - public String example() { - return null; - } -} diff --git a/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java b/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java index 5724fa0..54298c6 100644 --- a/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java +++ b/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java @@ -16,7 +16,6 @@ package com.bbn.hadder.commands.owner; -import com.bbn.hadder.RethinkUser; import com.bbn.hadder.commands.Command; import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.core.Perm; @@ -39,8 +38,7 @@ public class BlacklistCommand implements Command { } else { switch (args[0].toLowerCase()) { case "add": - if (args.length == 3 && e.getMessage().getMentionedUsers().size() == 1) { - RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", e.getMessage().getMentionedUsers().get(0).getId()), e.getRethink()); + if (args.length == 3) { String blacklisted = e.getRethinkUser().getBlacklisted(); List commands = new ArrayList<>(); if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); @@ -49,19 +47,18 @@ public class BlacklistCommand implements Command { ArrayList commandsWithoutDuplicates = new ArrayList<>(hashSet); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); - u.setBlacklisted(newblacklisted); + e.getRethinkUser().setBlacklisted(newblacklisted); e.getTextChannel().sendMessage( e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.owner.blacklist.success.add.title", "", "commands.owner.blacklist.success.add.description", newblacklisted) .build()).queue(); - u.push(); - } else e.getHelpCommand().sendHelp(this, e); + e.getRethinkUser().push(); + } break; case "remove": - if (args.length == 3 && e.getMessage().getMentionedUsers().size() == 1) { - RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", e.getMessage().getMentionedUsers().get(0).getId()), e.getRethink()); + if (args.length == 3) { String blacklisted = e.getRethinkUser().getBlacklisted(); List commands = new ArrayList<>(); if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); @@ -70,22 +67,21 @@ public class BlacklistCommand implements Command { ArrayList commandsWithoutDuplicates = new ArrayList<>(hashSet); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); - u.setBlacklisted(newblacklisted); + e.getRethinkUser().setBlacklisted(newblacklisted); e.getTextChannel().sendMessage( e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.owner.blacklist.success.remove.title", "", "commands.owner.blacklist.success.remove.description", newblacklisted) .build()).queue(); - u.push(); - } else e.getHelpCommand().sendHelp(this, e); + e.getRethinkUser().push(); + } break; case "list": StringBuilder stringBuilder = new StringBuilder(); for (User user : e.getJDA().getUsers()) { if (!user.getId().equals(e.getJDA().getSelfUser().getId())) { - RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", user.getId()), e.getRethink()); - String blacklisted = u.getBlacklisted(); + String blacklisted = e.getRethinkUser().getBlacklisted(); if (!"none".equals(blacklisted)) { stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n"); } @@ -93,7 +89,7 @@ public class BlacklistCommand implements Command { } e.getTextChannel().sendMessage( e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) - .setTitle("Blacklisted Users") + .setTitle("Blacklisted Users:") .setDescription((stringBuilder.length()!=0) ? ("``" + stringBuilder.toString() + "``") : "No blacklisted Users") .build()).queue(); break; diff --git a/src/main/java/com/bbn/hadder/core/CommandHandler.java b/src/main/java/com/bbn/hadder/core/CommandHandler.java index 7ab130a..5f2029c 100644 --- a/src/main/java/com/bbn/hadder/core/CommandHandler.java +++ b/src/main/java/com/bbn/hadder/core/CommandHandler.java @@ -76,8 +76,8 @@ public class CommandHandler { } } } - if (run) cmd.executed(args, commandEvent); - else event.getMessage().addReaction("❌").queue(); + if (run) + cmd.executed(args, commandEvent); return; } } diff --git a/src/main/java/com/bbn/hadder/utils/BotList.java b/src/main/java/com/bbn/hadder/utils/BotList.java index cf5890b..8ea3167 100644 --- a/src/main/java/com/bbn/hadder/utils/BotList.java +++ b/src/main/java/com/bbn/hadder/utils/BotList.java @@ -36,6 +36,7 @@ public class BotList { private static String DiscordBoats = "https://discord.boats/api/bot/637002314162372639"; private static String YetAnotherBotList = "https://yabl.xyz/api/bot/637002314162372639/stats"; private static String DiscordExtremeList = "https://api.discordextremelist.xyz/v1/bot/637002314162372639"; + private static String DiscordBotReviews = "https://discordbotreviews.xyz/api/bot/637002314162372639/stats"; private static String DiscordBots = "https://top.gg/api/bots/637002314162372639/stats"; private static String BotListSpace = "https://api.botlist.space/v1/bots/637002314162372639"; private static String DiscordBots2 = "https://discord.bots.gg/api/v1/bots/637002314162372639/stats"; @@ -150,6 +151,21 @@ public class BotList { e.printStackTrace(); } + // Discord Bot Reviews + + Request discordbotreviews = new Request.Builder() + .url(DiscordBotReviews) + .post(body) + .addHeader("Authorization", config.getDiscordBotReviewsToken()) + .build(); + + try { + new OkHttpClient().newCall(discordbotreviews).execute().close(); + System.out.println("Successfully posted count to Discord Bot Reviews!"); + } catch (IOException e) { + e.printStackTrace(); + } + // Discord Bots Request discordbots = new Request.Builder() diff --git a/src/main/java/com/bbn/hadder/utils/MessageEditor.java b/src/main/java/com/bbn/hadder/utils/MessageEditor.java index c760b70..fcbbbe9 100644 --- a/src/main/java/com/bbn/hadder/utils/MessageEditor.java +++ b/src/main/java/com/bbn/hadder/utils/MessageEditor.java @@ -133,6 +133,6 @@ public class MessageEditor { ResourceBundle resourceBundle = ResourceBundle.getBundle("Translations/Translations", locale); if (resourceBundle.containsKey(string)) return resourceBundle.getString(string).replaceAll("%extra%", extra).replaceAll("%extra_two%", extra_two); - else return "This key doesn't exist. Please report this to the Bot Developers. Key: `" + string + "` Language_code: `" + language_code + "`"; + else return "This key doesn't exist. Please report this to the Bot Developers. Key: " + string + " Language_code: " + language_code; } } diff --git a/src/main/resources/Translations/Translations_de.properties b/src/main/resources/Translations/Translations_de.properties index e39527c..b71565c 100644 --- a/src/main/resources/Translations/Translations_de.properties +++ b/src/main/resources/Translations/Translations_de.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 = Erfolgreich gebannt commands.moderation.ban.success.description = Ich habe %extra% erfolgreich gebannt @@ -152,7 +157,7 @@ commands.moderation.rules.channel.error.title = Kanal konnte nicht gefunden werd commands.moderation.rules.channel.error.description = Ich kann den angegebenen Kanal nicht finden. Bitte starte das Setup erneut. commands.moderation.rules.rules.title = Regelnachricht commands.moderation.rules.rules.description = Der Kanal wurde erfolgreich auf %extra% gesetzt. Bitte senden Sie mir jetzt die Regeln. -commands.moderation.rules.role.title = Rolle zum Erhalten/Verlieren +commands.moderation.rules.role.title = Rolle zum Hinzufügen commands.moderation.rules.role.description = Die Regeln wurden erfolgreich festgelegt. Bitte sende mir den Namen der Rolle, die der Benutzer erhalten soll nachdem er die Regeln akzeptiert hat. commands.moderation.rules.role.error.title = Rolle existiert nicht commands.moderation.rules.role.error.description = The specified role does not exist on this guild. diff --git a/src/main/resources/Translations/Translations_es.properties b/src/main/resources/Translations/Translations_es.properties index 2f19d7d..75aaadd 100644 --- a/src/main/resources/Translations/Translations_es.properties +++ b/src/main/resources/Translations/Translations_es.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% diff --git a/src/main/resources/Translations/Translations_fr.properties b/src/main/resources/Translations/Translations_fr.properties index 2f19d7d..75aaadd 100644 --- a/src/main/resources/Translations/Translations_fr.properties +++ b/src/main/resources/Translations/Translations_fr.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% diff --git a/src/main/resources/Translations/Translations_ru.properties b/src/main/resources/Translations/Translations_ru.properties index 2f19d7d..75aaadd 100644 --- a/src/main/resources/Translations/Translations_ru.properties +++ b/src/main/resources/Translations/Translations_ru.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% diff --git a/src/main/resources/Translations/Translations_tr.properties b/src/main/resources/Translations/Translations_tr.properties index 2f19d7d..75aaadd 100644 --- a/src/main/resources/Translations/Translations_tr.properties +++ b/src/main/resources/Translations/Translations_tr.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% diff --git a/src/main/resources/Translations/Translations_zh.properties b/src/main/resources/Translations/Translations_zh.properties index 2f19d7d..75aaadd 100644 --- a/src/main/resources/Translations/Translations_zh.properties +++ b/src/main/resources/Translations/Translations_zh.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%