diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java index 06ed144..a996fb6 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/MGZBot.java @@ -7,6 +7,8 @@ import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.requests.GatewayIntent; +import zone.themcgamer.data.mysql.MySQLConstants; +import zone.themcgamer.data.mysql.MySQLController; import zone.themcgamer.discordbot.command.impl.*; import zone.themcgamer.discordbot.events.GuildsListener; import zone.themcgamer.discordbot.events.MainGuildListener; 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 01f60ab..b12462b 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/events/MainGuildListener.java @@ -6,6 +6,7 @@ import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; import net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import zone.themcgamer.common.TimeUtils; import zone.themcgamer.discordbot.BotConstants; import zone.themcgamer.discordbot.MGZBot; import zone.themcgamer.discordbot.utilities.EmbedUtils; @@ -15,6 +16,7 @@ import javax.annotation.Nonnull; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; import static zone.themcgamer.discordbot.utilities.GuildUtils.toggleRole; @@ -90,11 +92,11 @@ public class MainGuildListener extends ListenerAdapter { MessageReaction.ReactionEmote reactionEmote = event.getReactionEmote(); for (Map.Entry entry : reactionRoles.entrySet()) { if (reactionEmote.getName().equals(entry.getKey())) { + event.getReaction().removeReaction(member.getUser()).queue(); Role role = guild.getRoleById(entry.getValue()); if (role == null) continue; toggleRole(guild, member, role); - event.getReaction().removeReaction(member.getUser()).queue(); } } } diff --git a/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/GuildUtils.java b/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/GuildUtils.java index 22e3bc9..015bfbb 100644 --- a/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/GuildUtils.java +++ b/discordbot/src/main/java/zone/themcgamer/discordbot/utilities/GuildUtils.java @@ -8,6 +8,8 @@ import zone.themcgamer.discordbot.BotConstants; import zone.themcgamer.discordbot.MGZBot; import zone.themcgamer.discordbot.guild.Guild; +import java.util.concurrent.TimeUnit; + /** * @author Nicholas */ @@ -37,6 +39,13 @@ public class GuildUtils { member.getUser().openPrivateChannel().queue(privateChannel -> { privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue(); }, error -> { + EmbedBuilder embedBuilder = EmbedUtils.successEmbed(); + embedBuilder.setTitle("Role Manager"); + embedBuilder.setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")); + TextChannel textChannelById = guild.getTextChannelById(813139125195898880L); + if (textChannelById == null) + return; + textChannelById.sendMessage(embedBuilder.build()).queue(message -> message.delete().queueAfter(2, TimeUnit.SECONDS)); }); TextChannel textChannelById = MGZBot.getInstance().getJda().getTextChannelById(BotConstants.HAROLD_LOG);