From 385153630f09b33be5a12716c020a81cc31b6b4a Mon Sep 17 00:00:00 2001 From: Erik Zuuring Date: Thu, 14 Nov 2024 15:15:08 +0200 Subject: [PATCH] Fix nickname change ### Notes Change `member.user.username` to `member.displayName` to resolve username replacing the nickname in the event the initial member.nickname isn't grabbed. Remove excess logging on each server nicknames. --- discord-scripts/discord-webhook.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discord-scripts/discord-webhook.ts b/discord-scripts/discord-webhook.ts index bc1ab1c4..4c2ef543 100644 --- a/discord-scripts/discord-webhook.ts +++ b/discord-scripts/discord-webhook.ts @@ -59,10 +59,6 @@ export default async function webhookDiscord( if (!guild) throw new Error("Guild not found") await guild.members.fetch() - // WIP, output list of all members for matching - guild.members.cache.forEach((member) => { - robot.logger.info(`Username: ${member.user.username}`) - }) const matchedMember = guild.members.cache.find((member) => member.user.username.includes(username), @@ -84,7 +80,7 @@ export default async function webhookDiscord( if (!userId) throw new Error("User not found with the specified name") const member = await guild.members.fetch(userId) - const currentNickname = member.nickname || member.user.username + const currentNickname = member.nickname ?? member.displayName const suffixWithDate = date ? `(OOO ${date})` : "(OOO)" const suffixRegex = /\s*\(OOO.*$/