class User
extends
Baseexport class User extends BaseRepresents a user on Discord.
Constructors
constructor(client: Client<true>data: RawUserData)
Constructs a new instance of the User class
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
Use avatarDecorationData instead
The user avatar decoration's hash
avatarDecorationData : AvatarDecorationData | null
The user avatar decoration's data
The user banner's hash The user must be force fetched for this property to be present or be updated
bot : boolean
Whether or not the user is a bot
readonlycreatedAt : Date
The time the user was created at
readonlycreatedTimestamp : number
The timestamp the user was created at
readonlydefaultAvatarURL : 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
readonlydisplayName : string
The global name of this user, or their username if they don't have one
flags : Readonly<UserFlagsBitField> | null
The flags for this user
readonlyhexAccentColor : 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
id : Snowflake
The user's id
system : boolean
Whether the user is an Official Discord System user (part of the urgent message system)
readonlytag : 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?: BaseImageURLOptions) : string | null
A link to the user's avatar decoration.
avatarURL(options?: ImageURLOptions) : string | null
A link to the user's avatar.
bannerURL(options?: ImageURLOptions) : string | null | undefined
A link to the user's banner. See banner for more info
Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
displayAvatarURL(options?: ImageURLOptions) : string
A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned.
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.
fetchFlags(force?: boolean) : Promise<UserFlagsBitField>
Fetches this user's flags.
send(options: string | MessagePayload | MessageCreateOptions) : Promise<Message>
Sends a message to this user.
// Send a direct message
user.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${user.tag}`))
.catch(console.error);toString() : UserMention
When concatenated with a string, this automatically returns the user's mention instead of the User object.
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${user}!`);