From 04317339be09a4995f795b182c46875c2642b1b4 Mon Sep 17 00:00:00 2001 From: danthe1st Date: Sat, 23 Nov 2024 19:10:21 +0100 Subject: [PATCH] use onGuildMemberUpdate to work with member caching --- .../javabot/listener/PingableNameListener.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/discordjug/javabot/listener/PingableNameListener.java b/src/main/java/net/discordjug/javabot/listener/PingableNameListener.java index 55dcee007..c19bdc29a 100644 --- a/src/main/java/net/discordjug/javabot/listener/PingableNameListener.java +++ b/src/main/java/net/discordjug/javabot/listener/PingableNameListener.java @@ -6,7 +6,7 @@ import net.discordjug.javabot.util.StringUtils; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; -import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent; +import net.dv8tion.jda.api.events.guild.member.GuildMemberUpdateEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import java.io.IOException; @@ -46,20 +46,19 @@ public PingableNameListener(NotificationService notificationService) { @Override public void onGuildMemberJoin(GuildMemberJoinEvent event) { - checkNickname(event.getMember(), null); + checkNickname(event.getMember()); } - + @Override - public void onGuildMemberUpdateNickname(GuildMemberUpdateNicknameEvent event) { - checkNickname(event.getMember(), event.getNewNickname()); + public void onGuildMemberUpdate(GuildMemberUpdateEvent event) { + checkNickname(event.getMember()); } /** * Checks whether the given {@link Member}'s nickname should be changed. * @param member The {@link Member} to check. - * @param nickname The {@link Member}'s new Nickname, null if that does not exist. */ - private void checkNickname(Member member, String nickname) { + private void checkNickname(Member member) { if (!isPingable(member.getEffectiveName()) && !canBypassCheck(member)) { changeName(member); }