英文:
Why onGuildMemberLeave event not working (Discord Java JDA)
问题
The onGuildMemberLeave
event doesn't work and I don't know why. I tried to use intents, activate intent authorizations on discord.com, but still not fixed.
The JDABuilder
method:
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();
}
}
The onGuildMemberLeave
event (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();
}
}
}
What am I missing?
英文:
The onGuildMemberLeave
event doesn't work and I don't know why. I tried to use intents, activate intent authorizations on discord.com, but still not fixed.
The JDABuilder
method:
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();
}
}
The onGuildMemberLeave
event (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();
}
}
}
What am I missing?
答案1
得分: 0
你不应该使用已弃用的功能,比如 GuildMemberLeaveEvent
。
文档建议你使用代替的 GuildMemberRemoveEvent
。
英文:
You shouldn't be using deprecated features like the GuildMemberLeaveEvent
.
The documentation tells you to use GuildMemberRemoveEvent
instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论