class User
extends
Baseexport class User extends Base
Represents a user on Discord.
Constructors
client: Client<true>data: RawUserData)
constructor(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
AvatarDecorationData | null avatarDecorationData :
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
boolean bot :
Whether or not the user is a bot
readonlyDate createdAt :
The time the user was created at
readonlynumber createdTimestamp :
The timestamp the user was created at
readonlystring defaultAvatarURL :
A link to the user's default avatar
string discriminator :
The discriminator of this user '0'
, or a 4-digit stringified number if they're using the legacy username system
readonlystring displayName :
The global name of this user, or their username if they don't have one
Readonly<UserFlagsBitField> | null flags :
The flags for this user
readonlyHexColorString | null | undefined hexAccentColor :
The hexadecimal version of the user accent color, with a leading hash The user must be force fetched for this property to be present
Snowflake id :
The user's id
boolean system :
Whether the user is an Official Discord System user (part of the urgent message system)
readonlystring tag :
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
string username :
The username of the user
avatarDecorationURLoptions?: BaseImageURLOptions) : string | null (
A link to the user's avatar decoration.
avatarURLoptions?: ImageURLOptions = {}) : string | null (
A link to the user's avatar.
bannerURLoptions?: ImageURLOptions = {}) : string | null | undefined (
A link to the user's banner. See banner for more info
Creates a DM channel between the client and the user.
Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
displayAvatarURLoptions?: 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.
sendoptions: 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);
toStringUserMention () :
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}!`);