From 4a1f4871224657077fd6e93d56c25e5361b3c3f8 Mon Sep 17 00:00:00 2001 From: LaysDragon Date: Tue, 16 Jul 2024 11:42:50 +0800 Subject: [PATCH] feat(discord): add missing global_name field (#285) --- adapters/discord/src/types/user.ts | 4 +++- adapters/discord/src/utils.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/adapters/discord/src/types/user.ts b/adapters/discord/src/types/user.ts index 85c3431f..b5ed4838 100644 --- a/adapters/discord/src/types/user.ts +++ b/adapters/discord/src/types/user.ts @@ -8,6 +8,8 @@ export interface User { username: string /** the user's 4-digit discord-tag */ discriminator: string + /** the user's display name, if it is set. For bots, this is the application name */ + global_name?: string /** the user's avatar hash */ avatar?: string /** whether the user belongs to an OAuth2 application */ @@ -106,7 +108,7 @@ export enum VisibilityType { EVERYONE = 1, } -export interface UserUpdateEvent extends User {} +export interface UserUpdateEvent extends User { } declare module './gateway' { interface GatewayEvents { diff --git a/adapters/discord/src/utils.ts b/adapters/discord/src/utils.ts index a6f970c9..1619f973 100644 --- a/adapters/discord/src/utils.ts +++ b/adapters/discord/src/utils.ts @@ -16,6 +16,7 @@ export const sanitizeCode = (val: string) => val.replace(/(?<=`)(?=`)/g, '\u200b export const decodeUser = (user: Discord.User): Universal.User => ({ id: user.id, + nick: user.global_name, name: user.username, userId: user.id, avatar: user.avatar && `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,