Checking if bot is sending a dm to itself.
This commit is contained in:
parent
bb812615b9
commit
df6576ad10
@ -7,7 +7,6 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
|||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
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.GuildMemberRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberUpdateEvent;
|
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import zone.themcgamer.discordbot.BotConstants;
|
import zone.themcgamer.discordbot.BotConstants;
|
||||||
import zone.themcgamer.discordbot.MGZBot;
|
import zone.themcgamer.discordbot.MGZBot;
|
||||||
|
@ -31,6 +31,9 @@ public class GuildUtils {
|
|||||||
guild.removeRoleFromMember(member.getIdLong(), role).queue();
|
guild.removeRoleFromMember(member.getIdLong(), role).queue();
|
||||||
else guild.addRoleToMember(member.getIdLong(), role).queue();
|
else guild.addRoleToMember(member.getIdLong(), role).queue();
|
||||||
|
|
||||||
|
if (member.getUser() == MGZBot.getInstance().getJda().getSelfUser())
|
||||||
|
return;
|
||||||
|
|
||||||
member.getUser().openPrivateChannel().queue(privateChannel -> {
|
member.getUser().openPrivateChannel().queue(privateChannel -> {
|
||||||
privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue();
|
privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue();
|
||||||
}, error -> {
|
}, error -> {
|
||||||
|
Reference in New Issue
Block a user