Checking if bot is sending a dm to itself.

This commit is contained in:
Joel 2021-02-21 22:44:17 +01:00
parent bb812615b9
commit df6576ad10
2 changed files with 3 additions and 1 deletions

@ -7,7 +7,6 @@ import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberUpdateEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import zone.themcgamer.discordbot.BotConstants;
import zone.themcgamer.discordbot.MGZBot;

@ -31,6 +31,9 @@ public class GuildUtils {
guild.removeRoleFromMember(member.getIdLong(), role).queue();
else guild.addRoleToMember(member.getIdLong(), role).queue();
if (member.getUser() == MGZBot.getInstance().getJda().getSelfUser())
return;
member.getUser().openPrivateChannel().queue(privateChannel -> {
privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue();
}, error -> {