User

export class User extends Base
export class User extends Base
Represents a user on Discord.

Extends

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
Deprecated
avatarDecoration:string | null
Use avatarDecorationData instead
Deprecated
The user avatar decoration's hash
avatarDecorationData:AvatarDecorationData | null
The user avatar decoration's data
Whether or not the user is a bot
Readonly
client:Client<true>
The client that instantiated this
Inherited from Base
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
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 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
send(options):Promise<Message>
Sends a message to this user.
Example
// Send a direct message
user.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${user.tag}`))
.catch(console.error);
// Send a direct message
user.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${user.tag}`))
.catch(console.error);
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoThe options to provide
toJSON(...props):unknown
NameTypeOptionalDescription
...propsRecord<string, boolean | string>[]NoNone
Inherited from Base
toString():UserMention
When concatenated with a string, this automatically returns the user's mention instead of the User object.
Example
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${user}!`);
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${user}!`);
valueOf():string
send(options):Promise<Message<InGuild>>
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoNone
Inherited from PartialTextBasedChannelFields