From a9c076247b4ab39ff8e0383150d449e20fa30268 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 27 Jul 2022 01:22:13 +0200 Subject: [PATCH] famous userOrNick --- src/utils/misc.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 917fb74..0393cc0 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -1,3 +1,5 @@ +import { GuildMember } from 'discord.js'; + /** * Log module status. * @param {string} name Module name @@ -58,3 +60,19 @@ export const isImage = (filename: string) => { /jpg|jpeg|png|webp|gif/ )); }; + +/** + * String with pseudo and nickname if available. + * @param member Member + * @returns string + */ +export const userWithNickname = (member: GuildMember) => { + if (!member) { + return undefined; + } + if (member.nickname) { + return `${member.nickname} (${member.user.tag})`; + } else { + return member.user.tag; + } +};