为什么 onGuildMemberLeave 事件不起作用(Discord Java JDA)

Why onGuildMemberLeave event not working (Discord Java JDA)

onGuildMemberLeave 事件不起作用,我不知道为什么。我尝试使用意图,在 discord.com 上激活意图授权,但仍未修复。

JDABuilder方法:

public static void buildJDA(){
    try {
        jdaBuilder.createDefault(Configuration.getToken())
                .enableIntents(GatewayIntent.GUILD_PRESENCES,
                        GatewayIntent.GUILD_BANS,
                        GatewayIntent.DIRECT_MESSAGES,
                        GatewayIntent.DIRECT_MESSAGE_REACTIONS,
                        GatewayIntent.GUILD_MEMBERS,
                        GatewayIntent.GUILD_INVITES)
                .enableCache(CacheFlag.ACTIVITY,
                        CacheFlag.CLIENT_STATUS,
                        CacheFlag.EMOTE,
                        CacheFlag.MEMBER_OVERRIDES)
                .addEventListeners(new JdaManager())
                .addEventListeners(new EngineListeners())
                .addEventListeners(new ElkirListeners())
                .build();
    } catch (LoginException e) {
        e.printStackTrace();
    }
}

onGuildMemberLeave 事件(ElkirListener):

@Override
public void onGuildMemberLeave(@Nonnull GuildMemberLeaveEvent event) {

    if(!Configuration.isSnapshotEnabled()){

        if(event.getGuild().getId().equalsIgnoreCase("701834905021186090")){
            EmbedBuilder builder = new EmbedBuilder()
                    .setAuthor(event.getUser().getAsTag(), null, event.getUser().getAvatarUrl())
                    .setColor(Color.red)
                    .setDescription("Tu nous à quittés, bonne continuation mon ami.");

            event.getGuild().getTextChannelById("701898572534382592").sendMessage(builder.build()).queue();
        }

        if(event.getGuild().getId().equalsIgnoreCase("465583093357477896")){
            EmbedBuilder builder = new EmbedBuilder()
                    .setAuthor(event.getUser().getAsTag(), null, event.getUser().getAvatarUrl())
                    .setColor(Color.red)
                    .setDescription("Tu nous à quitté, bonne continuation mon ami.");

            event.getGuild().getTextChannelById("568803340541231125").sendMessage(builder.build()).queue();
        }
    }
}

我错过了什么?

您不应使用已弃用 功能,例如GuildMemberLeaveEvent

文档告诉您改用 GuildMemberRemoveEvent