From 0d0b8affbc8aa27cd8aa357bb54575e1201442ab Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Wed, 1 Jan 2020 16:49:08 +0100 Subject: [PATCH 1/9] Some code improvements again --- example-config.json | 3 ++- src/main/java/com/bbn/hadder/Hadder.java | 2 +- src/main/java/com/bbn/hadder/Rethink.java | 4 ++-- ...StarBoardCommand.java => StarboardCommand.java} | 4 ++-- .../hadder/commands/owner/BlacklistCommand.java | 14 ++++++++++---- .../java/com/bbn/hadder/core/CommandHandler.java | 2 +- .../com/bbn/hadder/listener/StarboardListener.java | 4 ++-- .../java/com/bbn/hadder/utils/MessageEditor.java | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) rename src/main/java/com/bbn/hadder/commands/moderation/{StarBoardCommand.java => StarboardCommand.java} (93%) diff --git a/example-config.json b/example-config.json index 437ec97..f787317 100644 --- a/example-config.json +++ b/example-config.json @@ -19,7 +19,8 @@ "DiscordExtremeList": "", "DiscordBotReviews": "", "DiscordBots": "", - "BotListSpace": "" + "BotListSpace": "", + "DiscordBots2": "" }, "Clyde": "" } diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index fb55b0d..85ca64f 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -92,7 +92,7 @@ public class Hadder { new LanguageCommand(), new ClydeCommand(), new PlayCommand(), - new StarBoardCommand(), + new StarboardCommand(), new QueueCommand(), new InfoCommand(), new SkipCommand(), diff --git a/src/main/java/com/bbn/hadder/Rethink.java b/src/main/java/com/bbn/hadder/Rethink.java index 3d84e6a..3bf91a3 100644 --- a/src/main/java/com/bbn/hadder/Rethink.java +++ b/src/main/java/com/bbn/hadder/Rethink.java @@ -144,11 +144,11 @@ public class Rethink { return (String) this.get("user", "id", id, "blacklisted"); } - public void setNeededstars(String stars, String guild_id) { + public void setNeededStars(String stars, String guild_id) { this.update("server", guild_id, "neededstars", stars); } - public String getNeededstars(String guild_id) { + public String getNeededStars(String guild_id) { return (String) this.get("server", "id", guild_id, "neededstars"); } diff --git a/src/main/java/com/bbn/hadder/commands/moderation/StarBoardCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java similarity index 93% rename from src/main/java/com/bbn/hadder/commands/moderation/StarBoardCommand.java rename to src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java index 80d926c..080cd79 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/StarBoardCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java @@ -5,7 +5,7 @@ import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.utils.MessageEditor; import net.dv8tion.jda.api.entities.TextChannel; -public class StarBoardCommand implements Command { +public class StarboardCommand implements Command { @Override public void executed(String[] args, CommandEvent event) { @@ -29,7 +29,7 @@ public class StarBoardCommand implements Command { } if (args.length==2) { - event.getRethink().setNeededstars(args[1], event.getGuild().getId()); + event.getRethink().setNeededStars(args[1], event.getGuild().getId()); } } 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 1741edf..5aa61f1 100644 --- a/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java +++ b/src/main/java/com/bbn/hadder/commands/owner/BlacklistCommand.java @@ -31,7 +31,7 @@ public class BlacklistCommand implements Command { Member member = event.getMessage().getMentionedMembers().get(0); String blacklisted = event.getRethink().getBlackListed(member.getId()); List commands = new ArrayList<>(); - if (!blacklisted.equals("none")) commands.addAll(Arrays.asList(blacklisted.split(","))); + if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); commands.addAll(Arrays.asList(args[1].split(","))); LinkedHashSet hashSet = new LinkedHashSet<>(commands); @@ -45,12 +45,13 @@ public class BlacklistCommand implements Command { .build()).queue(); } break; + case "remove": if (args.length == 3) { Member member = event.getMessage().getMentionedMembers().get(0); String blacklisted = event.getRethink().getBlackListed(member.getId()); List commands = new ArrayList<>(); - if (!blacklisted.equals("none")) commands.addAll(Arrays.asList(blacklisted.split(","))); + if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); commands.removeAll(Arrays.asList(args[1].split(","))); LinkedHashSet hashSet = new LinkedHashSet<>(commands); @@ -64,12 +65,13 @@ public class BlacklistCommand implements Command { .build()).queue(); } break; + case "list": StringBuilder stringBuilder = new StringBuilder(); for (User user : event.getJDA().getUsers()) { if (!user.getId().equals(event.getJDA().getSelfUser().getId())) { String blacklisted = event.getRethink().getBlackListed(user.getId()); - if (!blacklisted.equals("none")) { + if (!"none".equals(blacklisted)) { stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n"); } } @@ -80,6 +82,10 @@ public class BlacklistCommand implements Command { .setDescription((stringBuilder.length()!=0) ? ("``" + stringBuilder.toString() + "``") : "No blacklisted Users") .build()).queue(); break; + + default: + event.getHelpCommand().sendHelp(this, event); + break; } } } @@ -101,6 +107,6 @@ public class BlacklistCommand implements Command { @Override public String example() { - return "add porn @Skidder"; + return "add solo @Skidder"; } } diff --git a/src/main/java/com/bbn/hadder/core/CommandHandler.java b/src/main/java/com/bbn/hadder/core/CommandHandler.java index 0a575df..775ad94 100644 --- a/src/main/java/com/bbn/hadder/core/CommandHandler.java +++ b/src/main/java/com/bbn/hadder/core/CommandHandler.java @@ -50,7 +50,7 @@ public class CommandHandler { boolean run = true; String blacklisted = rethink.getBlackListed(event.getAuthor().getId()); - if (!blacklisted.equals("none")) { + if (!"none".equals(blacklisted)) { for (String blacklistedlabel : blacklisted.split(",")) { if (Arrays.asList(cmd.labels()).contains(blacklistedlabel)) { run = false; diff --git a/src/main/java/com/bbn/hadder/listener/StarboardListener.java b/src/main/java/com/bbn/hadder/listener/StarboardListener.java index 8bdf694..38c5c52 100644 --- a/src/main/java/com/bbn/hadder/listener/StarboardListener.java +++ b/src/main/java/com/bbn/hadder/listener/StarboardListener.java @@ -43,7 +43,7 @@ public class StarboardListener extends ListenerAdapter { } } - if (Integer.parseInt(rethink.getNeededstars(event.getGuild().getId())) <= stars) { + if (Integer.parseInt(rethink.getNeededStars(event.getGuild().getId())) <= stars) { event.getGuild().getTextChannelById(rethink.getStarboardChannel(event.getGuild().getId())) .sendMessage(new MessageBuilder() .setContent("⭐ 1" + " " + event.getTextChannel().getAsMention()) @@ -77,7 +77,7 @@ public class StarboardListener extends ListenerAdapter { .retrieveMessageById(rethink.getStarboardMessage(event.getMessageId())).queue( msg2 -> { - if (Integer.parseInt(rethink.getNeededstars(event.getGuild().getId())) <= finalStars) { + if (Integer.parseInt(rethink.getNeededStars(event.getGuild().getId())) <= finalStars) { msg2.editMessage(new MessageBuilder() .setContent("⭐ " + finalStars + " " + event.getTextChannel().getAsMention()) .setEmbed( diff --git a/src/main/java/com/bbn/hadder/utils/MessageEditor.java b/src/main/java/com/bbn/hadder/utils/MessageEditor.java index 1d39039..4e923ee 100644 --- a/src/main/java/com/bbn/hadder/utils/MessageEditor.java +++ b/src/main/java/com/bbn/hadder/utils/MessageEditor.java @@ -36,8 +36,8 @@ public class MessageEditor { String description, String description_extra, String description_extra_two) { String language = (this.user!=null) ? rethink.getLanguage(this.user.getId()) : null; EmbedBuilder eb = this.getDefaultSettings(type); - if (!title.equals("")) eb.setTitle(this.handle(language, title, title_extra, title_extra_two)); - if (!description.equals("")) eb.setDescription(this.handle(language, description, description_extra, description_extra_two)); + if (!"".equals(title)) eb.setTitle(this.handle(language, title, title_extra, title_extra_two)); + if (!"".equals(description)) eb.setDescription(this.handle(language, description, description_extra, description_extra_two)); return eb; } From 815c9bab797680bf9448c602054f72518ca0d719 Mon Sep 17 00:00:00 2001 From: Skidder Date: Thu, 2 Jan 2020 17:47:16 +0100 Subject: [PATCH 2/9] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 20d142d..b7cfdc4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Hadder Discord is a multi-purpose Discord bot with 100% uptime. [![Crowdin](https://badges.crowdin.net/e/bc0babde730eb3eada34778502a31b03/localized.svg)](https://bbn.crowdin.com/hadder) [![GitHub issues](https://img.shields.io/github/issues/BigBotNetwork/Hadder)](https://github.com/BigBotNetwork/Hadder/issues) [![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) [![Discord Bots](https://top.gg/api/widget/637002314162372639.svg)](https://top.gg/bot/637002314162372639) From c0489f793ef01c81121834ce8365419842289cb5 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Thu, 2 Jan 2020 20:39:37 +0100 Subject: [PATCH 3/9] Little spelling fix --- .../com/bbn/hadder/commands/moderation/ClearCommand.java | 4 ++-- src/main/resources/Translations/Translations_en.properties | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java index 0dbf1da..12d1a58 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/ClearCommand.java @@ -30,9 +30,9 @@ public class ClearCommand implements Command { } Message message = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage( MessageEditor.MessageType.INFO, - "commands.moderation.lear.all.success.title", + "commands.moderation.clear.all.success.title", "", - "commands.moderation.lear.all.success.description", + "commands.moderation.clear.all.success.description", String.valueOf(msg.size())) .build()).complete(); try { diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 0ca8de0..76ecd48 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -45,8 +45,8 @@ commands.misc.feedback.title.request.title = Feedback Topic commands.misc.feedback.title.request.description = Please send me the feedback topic. commands.misc.feedback.description.request.title = Feedback Description commands.misc.feedback.description.request.description = Please send me the feedback description now. -commands.misc.feedback.help.description = Sends feedback directly to the developers. commands.misc.feedback.success.title = Feedback successfully sent\! +commands.misc.feedback.help.description = Sends feedback directly to the developers. commands.misc.github.link.title = Link your GitHub Account commands.misc.github.success.title = Information about %extra% commands.misc.github.success.bio = User bio @@ -81,8 +81,8 @@ commands.moderation.ban.myself.error.description = I can not ban myself\! commands.moderation.ban.yourself.error.description = You can not ban yourself\! commands.moderation.ban.massban.success.description = I successfully banned %extra% members\! commands.moderation.ban.help.description = Bans one or more users from the server. -commands.moderation.lear.all.success.title = Successfully deleted -commands.moderation.lear.all.success.description = I successfully deleted %extra% messages. +commands.moderation.clear.all.success.title = Successfully deleted +commands.moderation.clear.all.success.description = I successfully deleted %extra% messages. commands.moderation.clear.number.error.title = Invalid number commands.moderation.clear.number.error.description = You have to choose a number between 1 and 99\! commands.moderation.clear.success.title = Successfully cleared From 872320b3041f076a15cb3faa7e44ccf1259f7a55 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Thu, 2 Jan 2020 20:46:17 +0100 Subject: [PATCH 4/9] Starboard help fix --- .../com/bbn/hadder/commands/moderation/StarboardCommand.java | 2 +- src/main/resources/Translations/Translations_en.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java index 080cd79..d3c97ff 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/StarboardCommand.java @@ -40,7 +40,7 @@ public class StarboardCommand implements Command { @Override public String description() { - return "Sets the starboard channel"; + return "commands.moderation.starboard.help.description"; } @Override diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index 76ecd48..b499a8e 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -153,6 +153,7 @@ commands.moderation.rules.error.message.title = Can't write messages commands.moderation.rules.error.message.description = I can not write messages in the specified channel commands.moderation.rules.help.description = Setup the rules on your Discord server commands.moderation.starboard.success.title = Successfully set the Channel\! +commands.moderation.starboard.help.description = Sets the starboard channel commands.moderation.editrules.channel.title = Rules channel commands.moderation.editrules.channel.description = Please send me the channel with the rules as mention commands.moderation.editrules.channel.found.error.title = Channel not found From ad598590b65deb29a08d94d500fc7d14b0838d0e Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Thu, 2 Jan 2020 22:41:04 +0100 Subject: [PATCH 5/9] New bot list --- README.md | 35 +++++++++++++++++++ src/main/java/com/bbn/hadder/core/Config.java | 8 ++--- .../java/com/bbn/hadder/utils/BotList.java | 32 ++++++++--------- .../Translations/Translations_en.properties | 16 ++++----- 4 files changed, 63 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index b7cfdc4..11518a2 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,38 @@ Hax#6775 ### Designer TopComp#1288 + +## A few commands +| **Command** | **Description** | +|----------------|---------------------------------------------------------------| +| h.help | Shows each command and explains its usage. | +| h.about | Shows information about Hadder. | +| h.equals | Checks if two strings are the same. | +| h.invite | Shows the invitation link to invite Hadder to your server. | +| h.ping | Shows the ping to the Discord API. | +| h.avatar | Sends the avatar of the specified member. | +| h.gif | Looks for a GIF on Giphy. | +| h.meme | Sends you a random meme. | +| h.clyde | Sends a message as a webhook named Clyde. | +| h.feedback | Sends feedback directly to the developers. | +| h.github | Displays information about a GitHub user profile. | +| h.screenshare | Shows you the link to share your screen. | +| h.ban | Bans one or more users from the server. | +| h.clear | Deletes the specified number of messages. | +| h.prefix | Sets the Guild-Prefix. | +| h.invitedetect | Activate or deactivate the Discord invite link detection. | +| h.kick | Kicks one or more user from the server. | +| h.nick | Rename a one or more user. | +| h.regionchange | Changes the server region to locked regions. | +| h.role | Adds and removes one or more role(s) from one or more user(s) | +| h.rules | Setup the rules on your Discord server | +| h.starboard | Sets the starboard channel. | +| h.editrules | Edits the rules message. | +| h.join | Joins your voice channel. | +| h.leave | Leaves your voice channel. | +| h.play | Plays the specified song. | +| h.stop | Stops the song. | +| h.info | Shows information about the playing song. | +| h.queue | Shows the music queue. | +| h.skip | Skips the currently playing song. | +| h.volume | Change the volume of the music. | diff --git a/src/main/java/com/bbn/hadder/core/Config.java b/src/main/java/com/bbn/hadder/core/Config.java index 6123713..942c382 100644 --- a/src/main/java/com/bbn/hadder/core/Config.java +++ b/src/main/java/com/bbn/hadder/core/Config.java @@ -115,10 +115,6 @@ public class Config { return config.getJSONObject("Tokens").getString("DiscordBotList"); } - public String getDiscordBestBotsToken() { - return config.getJSONObject("Tokens").getString("DiscordBestBots"); - } - public String getDiscordBoatsToken() { return config.getJSONObject("Tokens").getString("DiscordBoats"); } @@ -147,6 +143,10 @@ public class Config { return config.getJSONObject("Tokens").getString("DiscordBots2"); } + public String getCloudListToken() { + return config.getJSONObject("Tokens").getString("CloudList"); + } + public String getClydeName() { return config.getString("Clyde"); } diff --git a/src/main/java/com/bbn/hadder/utils/BotList.java b/src/main/java/com/bbn/hadder/utils/BotList.java index 462f823..6200c4e 100644 --- a/src/main/java/com/bbn/hadder/utils/BotList.java +++ b/src/main/java/com/bbn/hadder/utils/BotList.java @@ -21,7 +21,6 @@ public class BotList { private static String MythicalBotList = "https://mythicalbots.xyz/api/bot/637002314162372639"; private static String BotsForDiscord = "https://botsfordiscord.com/api/bot/637002314162372639"; private static String DiscordBotList = "https://discordbotlist.com/api/bots/637002314162372639/stats"; - private static String DiscordBestBots = "https://discordsbestbots.xyz/api/bots/637002314162372639/stats"; 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"; @@ -29,6 +28,7 @@ public class BotList { 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"; + private static String CloudList = "https://www.cloudlist.xyz/api/stats/637002314162372639"; private Config config; @@ -93,21 +93,6 @@ public class BotList { e.printStackTrace(); } - // Discord Best Bots - - Request discordbestbots = new Request.Builder() - .url(DiscordBestBots) - .post(body) - .addHeader("Authorization", config.getDiscordBestBotsToken()) - .build(); - - try { - new OkHttpClient().newCall(discordbestbots).execute().close(); - System.out.println("Successfully posted count to Discord Best Bots!"); - } catch (IOException e) { - e.printStackTrace(); - } - // Discord Boats Request discordboats = new Request.Builder() @@ -212,6 +197,21 @@ public class BotList { } catch (IOException e) { e.printStackTrace(); } + + // CloudList + + Request cloudlist = new Request.Builder() + .url(CloudList) + .post(body) + .addHeader("Authorization", config.getCloudListToken()) + .build(); + + try { + new OkHttpClient().newCall(cloudlist).execute().close(); + System.out.println("Successfully posted count to the CloudList!"); + } catch (IOException e) { + e.printStackTrace(); + } } } } diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index b499a8e..d4f0582 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -153,7 +153,7 @@ commands.moderation.rules.error.message.title = Can't write messages commands.moderation.rules.error.message.description = I can not write messages in the specified channel commands.moderation.rules.help.description = Setup the rules on your Discord server commands.moderation.starboard.success.title = Successfully set the Channel\! -commands.moderation.starboard.help.description = Sets the starboard channel +commands.moderation.starboard.help.description = Sets the starboard channel. commands.moderation.editrules.channel.title = Rules channel commands.moderation.editrules.channel.description = Please send me the channel with the rules as mention commands.moderation.editrules.channel.found.error.title = Channel not found @@ -176,12 +176,12 @@ commands.music.join.error.connecting.trying.title = Already trying to connect commands.music.join.error.connecting.trying.description = Hadder is already trying to connect. Please wait a moment commands.music.join.error.channel.title = No Voice Channel commands.music.join.error.channel.description = You aren't in a Voice Channel. -commands.music.join.help.description = Joins your voice channel +commands.music.join.help.description = Joins your voice channel. commands.music.leave.success.title = Successfully disconnected commands.music.leave.success.description = I successfully disconnected from the Voice Channel commands.music.leave.error.tile = Not connected commands.music.leave.error.description = I'm currently in no Voice Channel on this Guild -commands.music.leave.help.description = Leaves a voice channel +commands.music.leave.help.description = Leaves your voice channel. commands.music.play.load.title = %extra% Now loading %extra% commands.music.play.load.description = Trying to load the song... commands.music.play.success.loading.title = %extra% Now playing %extra% @@ -193,22 +193,22 @@ commands.music.play.error.load.title = %extra% Load failed %extra% commands.music.play.error.load.description = Unfortunately I can not load the given song commands.music.play.error.match.title = %extra% No matches %extra% commands.music.play.error.match.description = I can not find a song named this on YouTube -commands.music.play.help.description = Plays a song +commands.music.play.help.description = Plays the specified song. commands.music.stop.success.title = Successfully stopped commands.music.stop.success.description = I successfully stopped the song. +commands.music.stop.help.description = Stops the song. commands.music.info.success.title = Track info commands.music.info.error.title = No playing track commands.music.info.error.description = I am not playing anything at the moment -commands.music.info.help.description = Shows information about the playing song -commands.music.stop.help.description = Stops the song +commands.music.info.help.description = Shows information about the playing song. commands.music.queue.error.title = No queue commands.music.queue.error.description = There are no queued songs at the moment commands.music.queue.success.title = Queue commands.music.queue.success.description = This is the queue\: \n %extra% -commands.music.queue.help.description = Shows the music queue +commands.music.queue.help.description = Shows the music queue. commands.music.skip.success.title = Successfully skipped commands.music.skip.success.description = I successfully skipped to the next song -commands.music.skip.help.description = Skips the currently playing song +commands.music.skip.help.description = Skips the currently playing song. commands.music.volume.success.title = Successfully set commands.music.volume.success.description = I successfully set the new volume to %extra% commands.music.volume.error.int.title = Invalid number From 8cb9613fd64e8931dacf88f467c81570462a3f18 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Thu, 2 Jan 2020 22:42:28 +0100 Subject: [PATCH 6/9] New JSON String... --- src/main/java/com/bbn/hadder/utils/BotList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/bbn/hadder/utils/BotList.java b/src/main/java/com/bbn/hadder/utils/BotList.java index 6200c4e..580a457 100644 --- a/src/main/java/com/bbn/hadder/utils/BotList.java +++ b/src/main/java/com/bbn/hadder/utils/BotList.java @@ -42,6 +42,7 @@ public class BotList { json.put("server_count", Hadder.shardManager.getGuilds().size()); json.put("guildCount", Hadder.shardManager.getGuilds().size()); json.put("guilds", Hadder.shardManager.getGuilds().size()); + json.put("count", Hadder.shardManager.getGuilds().size()); json.put("users", Hadder.shardManager.getUsers().size()); json.put("shard_count", Hadder.shardManager.getShards().size()); json.put("shardCount", Hadder.shardManager.getShards().size()); From 58a539a789323a8428b09d9e924721b8e52ab601 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2020 13:50:40 +0000 Subject: [PATCH 7/9] Bump JDA from 4.1.0_90 to 4.1.0_93 Bumps JDA from 4.1.0_90 to 4.1.0_93. Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 79ee1d3..712e13f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ net.dv8tion JDA - 4.1.0_90 + 4.1.0_93 org.json From 912dba9158f5e1dda1275623755aa71ef647e81f Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Fri, 3 Jan 2020 15:25:45 +0100 Subject: [PATCH 8/9] Custom error messages --- .../java/com/bbn/hadder/commands/music/JoinCommand.java | 7 +++---- src/main/java/com/bbn/hadder/core/CommandHandler.java | 9 +++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/bbn/hadder/commands/music/JoinCommand.java b/src/main/java/com/bbn/hadder/commands/music/JoinCommand.java index e0b2975..ceafccd 100644 --- a/src/main/java/com/bbn/hadder/commands/music/JoinCommand.java +++ b/src/main/java/com/bbn/hadder/commands/music/JoinCommand.java @@ -1,15 +1,14 @@ package com.bbn.hadder.commands.music; -/* - * @author Skidder / GregTCLTK - */ - import com.bbn.hadder.commands.Command; import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.utils.MessageEditor; import net.dv8tion.jda.api.entities.VoiceChannel; import net.dv8tion.jda.api.managers.AudioManager; +/* + * @author Skidder / GregTCLTK + */ public class JoinCommand implements Command { diff --git a/src/main/java/com/bbn/hadder/core/CommandHandler.java b/src/main/java/com/bbn/hadder/core/CommandHandler.java index 775ad94..c55a4da 100644 --- a/src/main/java/com/bbn/hadder/core/CommandHandler.java +++ b/src/main/java/com/bbn/hadder/core/CommandHandler.java @@ -41,8 +41,9 @@ public class CommandHandler { for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) { if (!perm.check(commandEvent)) { commandEvent.getTextChannel() - .sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION).build()) - .queue(); + .sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION) + .setDescription("To execute this command, you need the `" + cmd.getClass().getAnnotation(Perms.class).value()[0] + "` permission.") + .build()).queue(); return; } } @@ -51,8 +52,8 @@ public class CommandHandler { boolean run = true; String blacklisted = rethink.getBlackListed(event.getAuthor().getId()); if (!"none".equals(blacklisted)) { - for (String blacklistedlabel : blacklisted.split(",")) { - if (Arrays.asList(cmd.labels()).contains(blacklistedlabel)) { + for (String BLLabel : blacklisted.split(",")) { + if (Arrays.asList(cmd.labels()).contains(BLLabel)) { run = false; } } From ba7eb974da4d336c4d50336628c5bdb41034be0d Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Fri, 3 Jan 2020 15:35:51 +0100 Subject: [PATCH 9/9] #264 --- .../commands/moderation/RulesCommand.java | 195 +++++++++--------- .../Translations/Translations_en.properties | 2 + 2 files changed, 103 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java b/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java index 2ce9a4e..fc432c2 100644 --- a/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java +++ b/src/main/java/com/bbn/hadder/commands/moderation/RulesCommand.java @@ -82,8 +82,8 @@ public class RulesCommand implements Command { if (event3.getMessage().getMentionedRoles().size() == 1) { Role role = event3.getMessage().getMentionedRoles().get(0); setRole(event, channel, message, event3, role); - } else if (event3.getGuild().getRolesByName(event3.getMessage().getContentStripped(), true).size() > 0) { - Role role = event3.getGuild().getRolesByName(event3.getMessage().getContentStripped(), true).get(0); + } else if (event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).size() > 0) { + Role role = event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).get(0); setRole(event, channel, message, event3, role); } else { event3.getChannel().sendMessage( @@ -113,106 +113,113 @@ public class RulesCommand implements Command { public void setRole(CommandEvent event, TextChannel channel, String message, GuildMessageReceivedEvent event3, Role role) { if (event3.getGuild().getSelfMember().canInteract(role)) { - event3.getChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.moderation.rules.emote.accept.title", - "", - "commands.moderation.rules.emote.accept.description", role.getName()) - .build()).queue(); - event.getEventWaiter().newOnMessageEventWaiter(event4 -> { - if (event4.getMessage().getEmotes().size() == 1) { - Emote aemote = event4.getMessage().getEmotes().get(0); - event4.getChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.moderation.rules.emote.decline.title", "", - "commands.moderation.rules.emote.decline.description", String.valueOf(aemote)) - .build()).queue(); - event.getEventWaiter().newOnMessageEventWaiter(event5 -> { - Emote demote = event5.getMessage().getEmotes().get(0); - if (!aemote.equals(demote)) { - Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) - .setTitle("Rules") - .setDescription(message) - .build()).complete(); - try { - rules.addReaction(aemote).queue(); - rules.addReaction(demote).queue(); - event5.getChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.moderation.rules.success.title", - "", - "commands.moderation.rules.success.description", - channel.getAsMention()) + if (event3.getMember().canInteract(role)) { + event3.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.INFO, + "commands.moderation.rules.emote.accept.title", + "", + "commands.moderation.rules.emote.accept.description", role.getName()) + .build()).queue(); + event.getEventWaiter().newOnMessageEventWaiter(event4 -> { + if (event4.getMessage().getEmotes().size() == 1) { + Emote aemote = event4.getMessage().getEmotes().get(0); + event4.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.INFO, + "commands.moderation.rules.emote.decline.title", "", + "commands.moderation.rules.emote.decline.description", String.valueOf(aemote)) .build()).queue(); - } catch (Exception e) { - event5.getChannel().sendMessage( + event.getEventWaiter().newOnMessageEventWaiter(event5 -> { + Emote demote = event5.getMessage().getEmotes().get(0); + if (!aemote.equals(demote)) { + Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) + .setTitle("Rules") + .setDescription(message) + .build()).complete(); + try { + rules.addReaction(aemote).queue(); + rules.addReaction(demote).queue(); + event5.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.INFO, + "commands.moderation.rules.success.title", + "", + "commands.moderation.rules.success.description", + channel.getAsMention()) + .build()).queue(); + } catch (Exception e) { + event5.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.ERROR, + "error", + "commands.moderation.rules.emote.error.access.description") + .build()).queue(); + e.printStackTrace(); + } + event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote.toString(), demote.toString()); + } else { + event.getTextChannel().sendMessage( event.getMessageEditor().getMessage( MessageEditor.MessageType.ERROR, - "error", - "commands.moderation.rules.emote.error.access.description") - .build()).queue(); - e.printStackTrace(); + "commands.moderation.rules.emote.error.equal.title", + "commands.moderation.rules.emote.error.equal.description") + .build()).queue(); } - event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote.toString(), demote.toString()); - } else { - event.getTextChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.ERROR, - "commands.moderation.rules.emote.error.equal.title", - "commands.moderation.rules.emote.error.equal.description") - .build()).queue(); - } - }, event.getJDA(), event.getAuthor()); - } else { - String aemote = event4.getMessage().getContentRaw(); - event4.getChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.moderation.rules.emote.decline.title", - "commands.moderation.rules.emoji.decline.description") - .build()).queue(); - event.getEventWaiter().newOnMessageEventWaiter(event5 -> { - String demote = event5.getMessage().getContentRaw(); - if (!aemote.equals(demote)) { - Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) - .setTitle("Rules") - .setDescription(message) - .build()).complete(); - try { - rules.addReaction(aemote).queue(); - rules.addReaction(demote).queue(); - event5.getChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.INFO, - "commands.moderation.rules.success.title", - "", - "commands.moderation.rules.success.description", - channel.getAsMention()) + }, event.getJDA(), event.getAuthor()); + } else { + String aemote = event4.getMessage().getContentRaw(); + event4.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.INFO, + "commands.moderation.rules.emote.decline.title", + "commands.moderation.rules.emoji.decline.description") .build()).queue(); - } catch (Exception e) { - event5.getChannel().sendMessage( + event.getEventWaiter().newOnMessageEventWaiter(event5 -> { + String demote = event5.getMessage().getContentRaw(); + if (!aemote.equals(demote)) { + Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) + .setTitle("Rules") + .setDescription(message) + .build()).complete(); + try { + rules.addReaction(aemote).queue(); + rules.addReaction(demote).queue(); + event5.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.INFO, + "commands.moderation.rules.success.title", + "", + "commands.moderation.rules.success.description", + channel.getAsMention()) + .build()).queue(); + } catch (Exception e) { + event5.getChannel().sendMessage( + event.getMessageEditor().getMessage( + MessageEditor.MessageType.ERROR, + "error", + "commands.moderation.rules.emoji.error.description") + .build()).queue(); + e.printStackTrace(); + } + event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote, demote); + } else { + event.getTextChannel().sendMessage( event.getMessageEditor().getMessage( MessageEditor.MessageType.ERROR, - "error", - "commands.moderation.rules.emoji.error.description") - .build()).queue(); - e.printStackTrace(); + "commands.moderation.rules.emote.error.equal.title", + "commands.moderation.rules.emote.error.equal.description") + .build()).queue(); } - event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote, demote); - } else { - event.getTextChannel().sendMessage( - event.getMessageEditor().getMessage( - MessageEditor.MessageType.ERROR, - "commands.moderation.rules.emote.error.equal.title", - "commands.moderation.rules.emote.error.equal.description") - .build()).queue(); - } - }, event.getJDA(), event.getAuthor()); - } - }, event.getJDA(), event.getAuthor()); + }, event.getJDA(), event.getAuthor()); + } + }, event.getJDA(), event.getAuthor()); + } else { + event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.moderation.rules.role.permission.error.title", + "commands.moderation.rules.role.permission.error.description") + .build()).queue(); + } } else { event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue(); } diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index d4f0582..650848b 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -136,6 +136,8 @@ commands.moderation.rules.role.title = Role to assign commands.moderation.rules.role.description = The rules were successfully set. Please send me the name of the role which the user receives after he accepted the rules. commands.moderation.rules.role.error.title = Role does not exist commands.moderation.rules.role.error.description = The specified role does not exist on this guild. +commands.moderation.rules.role.permission.error.title = No permission +commands.moderation.rules.role.permission.error.description = You cannot select this role because you cannot interact with it. commands.moderation.rules.guild.error.title = Wrong Guild commands.moderation.rules.guild.error.description = The mentioned channel must be on this guild\! commands.moderation.rules.emote.accept.title = Custom Accept Emote