From 3468f8051802298f13d7388e5415e538f617aa71 Mon Sep 17 00:00:00 2001 From: nickreesdev Date: Mon, 15 Mar 2021 11:15:42 -0500 Subject: [PATCH] Discord Bot: Cleaned things up a little bit and fixed an issue where the panel wouldn't mark the bot server as RUNNING. --- .../zone/themcgamer/discordbot/BotConstants.java | 2 +- .../java/zone/themcgamer/discordbot/MGZBot.java | 2 +- .../command/impl/AddReactionToMessageCommand.java | 3 +-- .../command/impl/EditMessageCommand.java | 5 ++--- .../discordbot/command/impl/InviteCommand.java | 14 ++++---------- .../discordbot/command/impl/MessageCommand.java | 2 +- .../discordbot/command/impl/SuggestCommand.java | 2 +- .../discordbot/events/MainGuildListener.java | 8 ++++---- .../discordbot/utilities/MessageUtils.java | 3 +-- 9 files changed, 16 insertions(+), 25 deletions(-) diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/BotConstants.java b/discordbot/src/main/java/zone/themcgamer/discordbot/BotConstants.java index b81e384..cffba5e 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/BotConstants.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/BotConstants.java @@ -25,5 +25,5 @@ public class BotConstants { // Channels public static final String HAROLD_LOG = "813151182758608936"; - public static final String SUGGESTIONS = "802304706701426730"; // TODO: 2/15/2021 Change this to the main guild's suggestions channel when the bot is on the main guild. + public static final String SUGGESTIONS = "802304706701426730"; } \ No newline at end of file diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java index d187695..8466a8f 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java @@ -56,7 +56,7 @@ public class MGZBot { ex.printStackTrace(); } - System.out.println("Done (" + (System.currentTimeMillis() - time) + "ms)!"); + System.out.println("Done (" + (System.currentTimeMillis() - time) + ")! For help, type \"help\" or \"?\"\n"); } public static void main(String[] args) { diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/AddReactionToMessageCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/AddReactionToMessageCommand.java index 55e797e..7b39ec9 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/AddReactionToMessageCommand.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/AddReactionToMessageCommand.java @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.List; public class AddReactionToMessageCommand extends BaseCommand { - public AddReactionToMessageCommand() { name = "addreaction"; aliases = new String[]{"react"}; @@ -46,4 +45,4 @@ public class AddReactionToMessageCommand extends BaseCommand { event.reply(embedBuilder.build()); }); } -} +} \ No newline at end of file diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/EditMessageCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/EditMessageCommand.java index 0f020e6..f3f3fc7 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/EditMessageCommand.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/EditMessageCommand.java @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.List; public class EditMessageCommand extends BaseCommand { - public EditMessageCommand() { name = "edit"; aliases = new String[]{"editmessage"}; @@ -28,7 +27,7 @@ public class EditMessageCommand extends BaseCommand { @Override protected void execute(CommandEvent event, List args) { if (args.size() < 3) { - MessageUtils.sendUsageMessage(event.getTextChannel(),this); + MessageUtils.sendUsageMessage(event.getTextChannel(), this); return; } @@ -51,4 +50,4 @@ public class EditMessageCommand extends BaseCommand { event.reply("Message with this ID does not exist, are you sure this is the right id?"); }); } -} +} \ No newline at end of file diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/InviteCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/InviteCommand.java index 3df10aa..b46bd33 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/InviteCommand.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/InviteCommand.java @@ -10,10 +10,9 @@ import java.util.List; import java.util.concurrent.TimeUnit; public class InviteCommand extends BaseCommand { - public InviteCommand() { name = "invite"; - aliases = new String[]{"createinvite"}; + aliases = new String[] { "createinvite" }; help = "Create invite link via the bot"; guildOnly = true; guilds = Collections.singletonList(zone.themcgamer.discordbot.guild.Guild.MAIN); @@ -22,7 +21,6 @@ public class InviteCommand extends BaseCommand { @Override protected void execute(CommandEvent event, List args) { Guild guild = event.getGuild(); - TextChannel textChannelById = guild.getTextChannelById(791015530001596456L); if (textChannelById == null) return; @@ -31,12 +29,8 @@ public class InviteCommand extends BaseCommand { .setTemporary(true).queue(inviteLink -> { event.getMember().getUser().openPrivateChannel().queue(privateChannel -> { privateChannel.sendMessage("I have generated an invite link for you! This invite link will work for 24 hours! " + inviteLink.getUrl()).queue(); - event.reply("Check your dm's!"); - }, error -> { - event.replyError("Could not sent you a dm!"); - }); }, error -> { - event.replyError("Coulnd't create an invite link due an error!"); - }); - + event.reply("Check your DMs!"); + }, error -> event.replyError("Could not sent you a dm!")); + }, error -> event.replyError("Couldn't create an invite link due to an error!")); } } \ No newline at end of file diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MessageCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MessageCommand.java index 9940f05..531c83b 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MessageCommand.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/MessageCommand.java @@ -15,7 +15,7 @@ public class MessageCommand extends BaseCommand { public MessageCommand() { name = "message"; - aliases = new String[]{"say"}; + aliases = new String[] { "say" }; help = "Announce something in an embed format."; arguments = " <description>"; userPermissions = new Permission[] { Permission.ADMINISTRATOR }; diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/SuggestCommand.java b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/SuggestCommand.java index daff105..e90a8c0 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/SuggestCommand.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/command/impl/SuggestCommand.java @@ -19,7 +19,7 @@ import java.util.stream.Collectors; public class SuggestCommand extends BaseCommand { public SuggestCommand() { name = "suggest"; - aliases = new String[]{"suggestion"}; + aliases = new String[] { "suggestion" }; help = "Share a suggestion!"; arguments = "<suggestion>"; guildOnly = true; diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java b/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java index b4080a4..fc88a72 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java @@ -18,15 +18,15 @@ import java.util.Map; import static zone.themcgamer.discordbot.utilities.GuildUtils.toggleRole; @RequiredArgsConstructor -public class MainGuildListener extends ListenerAdapter { +public class MainGuildListener extends ListenerAdapter { private final MGZBot mgzBot; private static final HashMap<String, Long> reactionRoles = new HashMap<>(); static { - reactionRoles.put("🗞️", 812440883898875914L); - reactionRoles.put("📊", 813139198428839976L); - reactionRoles.put("🥁", 813140631705878549L); + reactionRoles.put("🗞️", 812440883898875914L); + reactionRoles.put("📊", 813139198428839976L); + reactionRoles.put("🥁", 813140631705878549L); } @Override diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/MessageUtils.java b/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/MessageUtils.java index 95c6fa4..1a39997 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/MessageUtils.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/MessageUtils.java @@ -10,7 +10,6 @@ import zone.themcgamer.discordbot.command.BaseCommand; import java.util.Objects; public class MessageUtils { - public static void sendUsageMessage(TextChannel textChannel, BaseCommand command) { textChannel.sendMessage(EmbedUtils.errorEmbed() .appendDescription("Usage: " + BotConstants.PREFIX + command.getName() + " " + command.getArguments()) @@ -36,4 +35,4 @@ public class MessageUtils { } return logChannel; } -} +} \ No newline at end of file