I have this event that has these problems.
this the event listener
@Override
public void onGuildAuditLogEntryCreate(GuildAuditLogEntryCreateEvent event) {
JDA jda=event.getJDA();
Guild gld=jda.getGuilds().get(0);
AuditLogPaginationAction auditLogs = event.getGuild().retrieveAuditLogs();
auditLogs.type(ActionType.MEMBER_VOICE_KICK);
auditLogs.limit(1);
auditLogs.queue( (entrys) ->
{
if (entrys.isEmpty()) return;
AuditLogEntry entry = entrys.get(0);
System.out.println("The User "+ entry.getUser().getId());
Member member=gld.getMemberById(entry.getUser().getId());
gld.modifyNickname(member,"User Voice kicker").queue();
});
}
What i am aiming at:
What i tried:
onGuildVoiceUpdate()
event.... i got the same problem.The event already provides you the created entry, you can just look at that one specifically.
public void onGuildAuditLogEntryCreate(GuildAuditLogEntryCreateEvent event) {
AuditLogEntry entry = event.getEntry();
if (entry.getType() != ActionType.MEMBER_VOICE_KICK) return; // guard case
String userId = entry.getUserId();
guild.retrieveMemberById(userId).flatMap(member ->
member.modifyNickname("User Voice kicker")
).queue();
}