feat(user)!: enhance user tag getter (#4652)

* feat: enhance user tag getter

* feat(user): add `0000` condition and better jsdoc for tag

* chore(user): use this keyword instead of destructuring assignment

* fix(user): correct isLegacy logic
This commit is contained in:
Louis Johnson
2025-12-23 17:24:01 +01:00
committed by GitHub
parent dabc8925cc
commit 624364e759
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -1784,7 +1784,7 @@ export interface User {
banner?: bigint
/** data for the user's avatar decoration */
avatarDecorationData?: AvatarDecorationData
/** The user tag in the form of username#discriminator */
/** The user tag in the form of `username` or `username#discriminator` for legacy username system */
tag: string
/** Whether the user belongs to an OAuth2 application */
bot: boolean
+2 -1
View File
@@ -11,7 +11,8 @@ export const baseUser: User = {
...(undefined as unknown as User),
get tag() {
return `${this.username}#${this.discriminator}`
const isLegacy = this.discriminator !== '0' && this.discriminator !== '0000'
return isLegacy ? `${this.username}#${this.discriminator}` : this.username
},
get bot() {
return !!this.toggles?.has('bot')