class ClientUser
extends
Userexport class ClientUser extends User
Represents the logged in client's Discord user.
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
Inherited from: User
AvatarDecorationData | null avatarDecorationData :
The user avatar decoration's data
Inherited from: User
The user banner's hash The user must be force fetched for this property to be present or be updated
Inherited from: User
string discriminator :
The discriminator of this user '0'
, or a 4-digit stringified number if they're using the legacy username system
Inherited from: User
readonlystring displayName :
The global name of this user, or their username if they don't have one
Inherited from: User
The DM between the client's user and this user
Inherited from: 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
Inherited from: User
readonlyClientPresence presence :
Represents the client user's presence
boolean system :
Whether the user is an Official Discord System user (part of the urgent message system)
Inherited from: User
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
Inherited from: User
boolean verified :
Whether or not this account has been verified
avatarDecorationURLoptions?: BaseImageURLOptions) : string | null (
A link to the user's avatar decoration.
Inherited from: User
avatarURLoptions?: ImageURLOptions) : string | null (
A link to the user's avatar.
Inherited from: User
bannerURLoptions?: ImageURLOptions) : string | null | undefined (
A link to the user's banner. See banner for more info
Inherited from: User
Creates a DM channel between the client and the user.
Inherited from: User
Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful.
Inherited from: User
displayAvatarURLoptions?: 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
editoptions: ClientUserEditOptions) : Promise<this> (
Edits the logged in client.
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
fetchFlagsforce?: boolean) : Promise<UserFlagsBitField> (
Fetches this user's flags.
Inherited from: User
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);
Inherited from: User
setActivityoptions?: ActivityOptions) : ClientPresence (
Sets the activity the client user is playing.
// Set the client user's activity
client.user.setActivity('discord.js', { type: ActivityType.Watching });
setAFK) : ClientPresence (
Sets/removes the AFK flag for the client user.
setAvataravatar: BufferResolvable | Base64Resolvable | null) : Promise<this> (
Sets the avatar of the logged in client.
// Set avatar
client.user.setAvatar('./avatar.png')
.then(user => console.log(`New avatar set!`))
.catch(console.error);
setBannerbanner: BufferResolvable | Base64Resolvable | null) : Promise<this> (
Sets the banner of the logged in client.
// Set banner
client.user.setBanner('./banner.png')
.then(user => console.log(`New banner set!`))
.catch(console.error);
setPresencedata: PresenceData) : ClientPresence (
Sets the full presence of the client user.
// Set the client user's presence
client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
setStatusstatus: PresenceStatusData) : ClientPresence (
Sets the status of the client user.
// Set the client user's status
client.user.setStatus('idle');
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!
// Set username
client.user.setUsername('discordjs')
.then(user => console.log(`My new username is ${user.username}`))
.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}!`);
Inherited from: User