10007: Unknown Member when trying to remove a reaction on user leave #1607
-
Hi there, I got a small issue when trying to remove a reaction when a users leaves the server. When trying to remove an emoji it works fine with the command.
However, the reaction get removed when the user leaves. Is there any way to fix this or should I just ignore the Exception Here is my code public class UserLeaveListener extends ListenerAdapter {
// ------------------------------------------------------
// Listens for user leaving the server
// ------------------------------------------------------
@Override
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
try {
// getting the guild from the event
Guild guild = event.getGuild();
// the ID of the rule accept message
long messageIDRule = 833117996460408843l;
// the ID of the role assign message
long messageIDRoleAssign = 833122315075846185l;
// get the user who left
User user = event.getUser();
// getting the custom emotes with the ID
Emote csgo = guild.retrieveEmoteById(831988425023422464l).complete();
Emote pubg = guild.retrieveEmoteById(831988460118081536l).complete();
// getting the text channel in which the rule accept message is placed
TextChannel rule = guild.getTextChannelById(831974686966546432l);
// getting the text channel in which the role assign message is placed
TextChannel selfRole = guild.getTextChannelById(831573505027604480l);
// remove the csgo and the pubg emote from the role assign message
selfRole.removeReactionById(messageIDRoleAssign, csgo, user).queue();
selfRole.removeReactionById(messageIDRoleAssign, pubg, user).queue();
// remove the :white-check-mark: emote from the rule message
rule.removeReactionById(messageIDRule, "U+2705", user).queue();
} catch(ErrorResponseException e) {
e.printStackTrace();
}
}
} And these are the settings I set and enabled in the main class: DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.createDefault(myToken);
builder.setStatus(OnlineStatus.ONLINE);
builder.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.DIRECT_MESSAGE_REACTIONS, GatewayIntent.GUILD_BANS);
builder.setChunkingFilter(ChunkingFilter.ALL);
builder.setMemberCachePolicy(MemberCachePolicy.ALL);
builder.enableCache(CacheFlag.ACTIVITY);
builder.enableCache(CacheFlag.CLIENT_STATUS);
builder.enableCache(CacheFlag.ONLINE_STATUS);
builder.enableCache(CacheFlag.MEMBER_OVERRIDES);
builder.addEventListeners(new UserLeaveListener());
builder.build(); Here is the strack trace:
These are my settings in the discord dev portal: I hope this is enough for you to support me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Edit: Original Post: Seems possible that discord is telling you It'll have to test to be sure. |
Beta Was this translation helpful? Give feedback.
Edit:
User stopped encountering the problem after updating to a newer version of JDA.
Original Post:
I haven't had a chance to test this yet but it looks like you're doing everything correctly. It is possible that this is a Discord bug.
Seems possible that discord is telling you
Unknown Member
because their systems are attempting to make sure that theuserId
being provided is a member of the current guild so that they can do permission checks to make sure your bot has permission to remove the reaction of the provided user. When their systems determine that the provided userId isn't in the guild there is probably an gate you're hitting that automatically responds withUnknown Member
.It'll…