class ClientUser

extends

User
export class ClientUser extends User

Represents the logged in client's Discord user.

optional
accentColor? : number

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

optional
avatar? : string

The user avatar's hash

optional
avatarDecoration? : string

The user avatar decoration's hash

The user banner's hash The user must be force fetched for this property to be present or be updated

optional
bot? : boolean

Whether or not the user is a bot

readonly
client : Client

The client that instantiated this

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

optional
discriminator? : string

The discriminator of this user '0', or a 4-digit stringified number if they're using the legacy username system

readonlyoptional
displayName? : string

The global name of this user, or their username if they don't have one

readonlyoptional
dmChannel? : DMChannel

The DM between the client's user and this user

optional
flags? : UserFlagsBitField

The flags for this user

optional
globalName? : string

The global name of this user

readonlyoptional
hexAccentColor? : string

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

mfaEnabled : boolean

If the bot's Owner has MFA enabled on their account

readonly
partial : boolean

Whether this User is a partial

readonly
presence : ClientPresence

Represents the client user's presence

optional
system? : boolean

Whether the user is an Official Discord System user (part of the urgent message system)

readonlyoptional
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

optional
username? : string

The username of the user

verified : boolean

Whether or not this account has been verified

avatarDecorationURL() : string | null

A link to the user's avatar decoration.

Inherited from: User

avatarURL(
options?: ImageURLOptions
) : string | null

A link to the user's avatar.

Inherited from: User

bannerURL(
options?: ImageURLOptions
) : string | null | undefined

A link to the user's banner. See banner for more info

Inherited from: User

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

Creates a DM channel between the client and the user.

Inherited from: User

deleteDM() : Promise<DMChannel>

Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.

Inherited from: User

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.

Inherited from: User

edit() : Promise<this>

Edits the logged in client.

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.

Inherited from: User

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

Fetches this user.

Inherited from: User

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

Fetches this user's flags.

Inherited from: User

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);

Inherited from: User

setActivity(
options?: ActivityOptions
) : ClientPresence

Sets the activity the client user is playing.

Examples:
// Set the client user's activity
client.user.setActivity('discord.js', { type: ActivityType.Watching });

setAFK(
afk?: boolean
shardId?: number | number[]
) : ClientPresence

Sets/removes the AFK flag for the client user.

setAvatar() : Promise<this>

Sets the avatar of the logged in client.

Examples:
// Set avatar
client.user.setAvatar('./avatar.png')
  .then(user => console.log(`New avatar set!`))
  .catch(console.error);

setPresence() : ClientPresence

Sets the full presence of the client user.

Examples:
// Set the client user's presence
client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });

setStatus(
shardId?: number | number[]
) : ClientPresence

Sets the status of the client user.

Examples:
// Set the client user's status
client.user.setStatus('idle');

setUsername(
username: string
) : Promise<this>

Sets the username of the logged in client. Changing usernames in Discord is heavily rate limited, with only 2 requests every hour. Use this sparingly!

Examples:
// Set username
client.user.setUsername('discordjs')
  .then(user => console.log(`My new username is ${user.username}`))
  .catch(console.error);

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}!`);

Inherited from: User