add name history tracking

This commit is contained in:
Lee
2024-06-30 03:36:00 +01:00
parent 91ecc9882c
commit 50391e5344
17 changed files with 537 additions and 10 deletions

View File

@ -7,10 +7,12 @@ import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
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.update.GuildMemberUpdateNicknameEvent;
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.user.update.UserUpdateGlobalNameEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@ -131,4 +133,29 @@ public class EventService extends ListenerAdapter {
listener.onModalInteraction(guild, user, event);
}
}
@Override
public void onUserUpdateGlobalName(@NotNull UserUpdateGlobalNameEvent event) {
if (event.getUser().isBot()) {
return;
}
BatUser user = userService.getUser(event.getUser().getId());
for (EventListener listener : LISTENERS) {
listener.onUserUpdateGlobalName(user, event.getOldGlobalName(), event.getNewGlobalName(), event);
}
}
@Override
public void onGuildMemberUpdateNickname(@NotNull GuildMemberUpdateNicknameEvent event) {
if (event.getUser().isBot()) {
return;
}
BatGuild guild = guildService.getGuild(event.getGuild().getId());
BatUser user = userService.getUser(event.getUser().getId());
for (EventListener listener : LISTENERS) {
listener.onGuildMemberUpdateNickname(guild, user, event.getOldNickname(), event.getNewNickname(), event);
}
}
}