Preview deployment

class User

extends

Base
export class User extends Base

Represents a user on Discord.

Constructors

constructor(
client: Client<true>
)

Constructs a new instance of the User class

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

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

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() : 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

createDM(
force?: boolean
) : Promise<DMChannel>

Creates a DM channel between the client and the user.

deleteDM() : Promise<DMChannel>

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.

equals(
user: 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.

fetch(
force?: boolean
) : Promise<User>

Fetches this user.

fetchFlags(
force?: boolean
) : Promise<UserFlagsBitField>

Fetches this user's flags.

Sends a message to this user.

Examples:
// Send a direct message
user.send('Hello!')
  .then(message => console.log(`Sent message: ${message.content} to ${user.tag}`))
  .catch(console.error);

toJSON(
...props: Record<string, boolean | string>[]
) : unknown

Inherited from: Base

toString() : UserMention

When concatenated with a string, this automatically returns the user's mention instead of the User object.

Examples:
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${user}!`);

valueOf() : string

Inherited from: Base