diff --git a/README.md b/README.md index 67adf75..db85607 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ 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) -[![Discord Extreme List](https://api.discordextremelist.xyz/v1/bot/637002314162372639/widget)](https://discordextremelist.xyz/bots/Hadder) +[![MBL](Https://Mythicalbots.Xyz/Bot/637002314162372639/Embed?Q=Dark/ )](Https://Mythicalbots.Xyz/Bot/637002314162372639) [![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 8060f47..7548e0f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Hadder Hadder - 1.0.2 + 1.0.3 Hadder @@ -56,7 +56,7 @@ net.dv8tion JDA - 4.1.1_105 + 4.1.1_108 org.json diff --git a/src/main/java/com/bbn/hadder/Rethink.java b/src/main/java/com/bbn/hadder/Rethink.java index 6bc066c..29b8346 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -18,6 +18,7 @@ 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; @@ -26,7 +27,6 @@ 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,7 +154,12 @@ public class Rethink { } // TODO public boolean hasStarboardMessage(String message_id) { - return this.getByID("stars", message_id, "guild") != null; + try { + this.getByID("stars", message_id, "guild"); + return true; + } catch (ReqlNonExistenceError e) { + return false; + } } @@ -185,5 +190,4 @@ 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 new file mode 100644 index 0000000..4503a3f --- /dev/null +++ b/src/main/java/com/bbn/hadder/commands/moderation/RoleAssignmentCommand.java @@ -0,0 +1,56 @@ +/* + * 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) { + //TODO: THIS LOL + 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 54298c6..5724fa0 100644 --- a/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java +++ b/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java @@ -16,6 +16,7 @@ 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; @@ -38,7 +39,8 @@ public class BlacklistCommand implements Command { } else { switch (args[0].toLowerCase()) { case "add": - if (args.length == 3) { + 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()); String blacklisted = e.getRethinkUser().getBlacklisted(); List commands = new ArrayList<>(); if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); @@ -47,18 +49,19 @@ public class BlacklistCommand implements Command { ArrayList commandsWithoutDuplicates = new ArrayList<>(hashSet); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); - e.getRethinkUser().setBlacklisted(newblacklisted); + u.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(); - e.getRethinkUser().push(); - } + u.push(); + } else e.getHelpCommand().sendHelp(this, e); break; case "remove": - if (args.length == 3) { + 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()); String blacklisted = e.getRethinkUser().getBlacklisted(); List commands = new ArrayList<>(); if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); @@ -67,21 +70,22 @@ public class BlacklistCommand implements Command { ArrayList commandsWithoutDuplicates = new ArrayList<>(hashSet); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); - e.getRethinkUser().setBlacklisted(newblacklisted); + u.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(); - e.getRethinkUser().push(); - } + u.push(); + } else e.getHelpCommand().sendHelp(this, e); break; case "list": StringBuilder stringBuilder = new StringBuilder(); for (User user : e.getJDA().getUsers()) { if (!user.getId().equals(e.getJDA().getSelfUser().getId())) { - String blacklisted = e.getRethinkUser().getBlacklisted(); + RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", user.getId()), e.getRethink()); + String blacklisted = u.getBlacklisted(); if (!"none".equals(blacklisted)) { stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n"); } @@ -89,7 +93,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 5f2029c..7ab130a 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); + if (run) cmd.executed(args, commandEvent); + else event.getMessage().addReaction("❌").queue(); return; } } diff --git a/src/main/java/com/bbn/hadder/utils/BotList.java b/src/main/java/com/bbn/hadder/utils/BotList.java index 8ea3167..cf5890b 100644 --- a/src/main/java/com/bbn/hadder/utils/BotList.java +++ b/src/main/java/com/bbn/hadder/utils/BotList.java @@ -36,7 +36,6 @@ 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"; @@ -151,21 +150,6 @@ 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 fcbbbe9..c760b70 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 + "`"; } }