User

export class User extends PartialTextBasedChannel(Base)
export class User extends PartialTextBasedChannel(Base)
Represents a user on Discord.

Extends

PartialTextBasedChannel(Base)
constructor(client, data)
Constructs a new instance of the User class
NameTypeOptionalDescription
clientClient<true>NoNone
dataRawUserDataNoNone
accentColor:number | null | undefined
The base 10 accent color of the user's banner The user must be force fetched for this property to be present or be updated
avatar:string | null
The user avatar's hash
avatarDecoration:string | null
The user avatar decoration's hash
bot:boolean
Whether or not the user is a bot
Readonly
createdAt:Date
The time the user was created at
Readonly
createdTimestamp:number
The timestamp the user was created at
Readonly
defaultAvatarURL:string
A link to the user's default avatar
discriminator:string
The discriminator of this user '0', or a 4-digit stringified number if they're using the legacy username system
Readonly
displayName:string
The global name of this user, or their username if they don't have one
Readonly
dmChannel:DMChannel | null
The DM between the client's user and this user
flags:Readonly<UserFlagsBitField> | null
The flags for this user
globalName:string | null
The global name of this user
Readonly
hexAccentColor:HexColorString | null | undefined
The hexadecimal version of the user accent color, with a leading hash The user must be force fetched for this property to be present
The user's id
Readonly
partial:false
Whether this User is a partial
system:boolean
Whether the user is an Official Discord System user (part of the urgent message system)
Readonly
tag:string
The tag of this user This user's username, or their legacy tag (e.g. hydrabolt#0001) if they're using the legacy username system
username:string
The username of the user
avatarDecorationURL(options?):string | null
A link to the user's avatar decoration.
Returns
NameTypeOptionalDescription
optionsBaseImageURLOptionsYesOptions for the image URL
avatarURL(options?):string | null
A link to the user's avatar.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
bannerURL(options?):string | null | undefined
A link to the user's banner. See banner for more info
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
createDM(force?):Promise<DMChannel>
Creates a DM channel between the client and the user.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
deleteDM():Promise<DMChannel>
Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
displayAvatarURL(options?):string
A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned.
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the Image URL
equals(user):boolean
Checks if the user is equal to another. It compares id, username, discriminator, avatar, banner, accent color, and bot flags. It is recommended to compare equality by using user.id === user2.id unless you want to compare all properties.
NameTypeOptionalDescription
userUserNoUser to compare with
fetch(force?):Promise<User>
Fetches this user.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
fetchFlags(force?):Promise<UserFlagsBitField>
Fetches this user's flags.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
toString():UserMention
When concatenated with a string, this automatically returns the user's mention instead of the User object.