Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nickname change #320

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions discord-scripts/discord-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this then fall back one more time on the username, or does display name handle that? What's the difference between display name and nickname? It feels like that might be backwards (display name being server specific and nick being global maybe?).

Copy link
Member Author

@zuuring zuuring Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nice part about member.displayName (doc link) is it will load Guild nickname again and then if a nickname isn't set, default to username.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only use that in that case?


const suffixWithDate = date ? `(OOO ${date})` : "(OOO)"
const suffixRegex = /\s*\(OOO.*$/
Expand Down
Loading