Skip to content

ClientUser

classe · Source

Represents the logged in client's Discord user.

Extends: User

Properties

verified

verified: boolean

Whether or not this account has been verified Source

mfaEnabled

nullable

mfaEnabled: boolean

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

purchasedFlags

purchasedFlags: Readonly<PurchasedFlags>

Purchased state of the client user. Source

premiumUsageFlags

premiumUsageFlags: Readonly<PremiumUsageFlags>

Premium usage state of the client user. Source

phone

nullable

phone: string

Phone number of the client user. Source

nsfwAllowed

nullable

nsfwAllowed: boolean

Whether or not the client user is allowed to send NSFW messages [iOS device]. Source

email

nullable

email: string

Email address of the client user. Source

bio

nullable

bio: string

About me (User) The user must be force fetched for this property to be present or be updated Source

pronouns

nullable

pronouns: string

Pronouns (User) The user must be force fetched for this property to be present or be updated Source

premiumType

premiumType: number

Premium types denote the level of premium a user has. Source

presence

readonly

presence: ClientPresence

Represents the client user's presence Source

id

id: Snowflake

The user's id Source

username

nullable

username: string

The username of the user Source

globalName

nullable

globalName: string

The global name of this user Source

bot

nullable

bot: boolean

Whether or not the user is a bot Source

discriminator

nullable

discriminator: string

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

avatar

nullable

avatar: string

The user avatar's hash Source

nullable

banner: string

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

bannerColor

nullable

bannerColor: string

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

accentColor

nullable

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 Source

system

nullable

system: boolean

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

flags

nullable

flags: UserFlags

The flags for this user Source

avatarDecorationData

nullable

avatarDecorationData: AvatarDecorationData

The user avatar decoration's data Source

primaryGuild

nullable

primaryGuild: UserPrimaryGuild

The primary guild of the user Source

collectibles

nullable

collectibles: Collectibles

The user's collectibles Source

clan

nullable · deprecated

clan: PrimaryGuild

The primary clan the user is in Source

avatarDecoration

nullable · deprecated

avatarDecoration: string

The user avatar decoration's hash Source

partial

readonly

partial: boolean

Whether this User is a partial Source

createdTimestamp

readonly

createdTimestamp: number

The timestamp the user was created at Source

createdAt

readonly

createdAt: Date

The time the user was created at Source

defaultAvatarURL

readonly

defaultAvatarURL: string

A link to the user's default avatar Source

hexAccentColor

readonly · nullable

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 Source

tag

readonly · nullable

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 Source

displayName

readonly · nullable

displayName: string

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

dmChannel

readonly · nullable

dmChannel: DMChannel

The DM between the client's user and this user Source

note

nullable

note: string

The function returns the note associated with a specific client ID from a cache. Source

voice

readonly

voice: VoiceState

The voice state of this member Source

relationship

readonly

relationship: RelationshipType

Check relationship status (Client -> User) Source

friendNickname

readonly · nullable

friendNickname: string

Get friend nickname Source

client

readonly

client: Client

The client that instantiated this Source

Methods

edit

async

async edit(options: ClientUserEditData): Promise<ClientUser>

Edits the logged in client. Parameters

NameTypeDescription
optionsClientUserEditDataThe new data

Returns: Promise<ClientUser>Source

setUsername

setUsername(username: string, password: string): Promise<ClientUser>

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! Parameters

NameTypeDescription
usernamestringThe new username
passwordstringCurrent Password

Returns: Promise<ClientUser>

js
// Set username
client.user.setUsername('discordjs', 'passw@rd')
  .then(user => console.log(`My new username is ${user.username}`))
  .catch(console.error);

Source

setAvatar

async

async setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise<ClientUser>

Sets the avatar of the logged in client. Parameters

NameTypeDescription
avatarBufferResolvable | Base64ResolvableThe new avatar

Returns: Promise<ClientUser>

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

Source

setPresence

setPresence(data: PresenceData): ClientPresence

Sets the full presence of the client user. Parameters

NameTypeDescription
dataPresenceDataData for the presence

Returns: ClientPresence

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

Source

setStatus

setStatus(status: PresenceStatusData, shardId?: number | Array<number>): ClientPresence

Sets the status of the client user. Parameters

NameTypeDescription
statusPresenceStatusDataStatus to change to
shardId?number | Array<number>Shard id(s) to have the activity set on

Returns: ClientPresence

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

Source

setActivity

setActivity(name: string | ActivityOptions, options?: ActivityOptions): ClientPresence

Sets the activity the client user is playing. Parameters

NameTypeDescription
namestring | ActivityOptionsActivity being played, or options for setting the activity
options?ActivityOptionsOptions for setting the activity

Returns: ClientPresence

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

Source

setAFK

setAFK(afk?: boolean, shardId?: number | Array<number>): ClientPresence

Sets/removes the AFK flag for the client user. Parameters

NameTypeDescription
afk?booleanWhether or not the user is AFK Default: true.
shardId?number | Array<number>Shard Id(s) to have the AFK flag set on

Returns: ClientPresenceSource

setBanner

async

async setBanner(banner: BufferResolvable | Base64Resolvable): Promise<ClientUser>

Sets the banner of the logged in client. Parameters

NameTypeDescription
bannerBufferResolvable | Base64ResolvableThe new banner

Returns: Promise<ClientUser>

js
// Set banner
client.user.setBanner('./banner.png')
  .then(user => console.log(`New banner set!`))
  .catch(console.error);

Source

setHypeSquad

setHypeSquad(type: string | number): Promise<void>

Set HyperSquad House Parameters

NameTypeDescription
typestring | number* LEAVE: 0
* HOUSE_BRAVERY: 1
* HOUSE_BRILLIANCE: 2
* HOUSE_BALANCE: 3

Returns: Promise<void>

js
// Set HyperSquad HOUSE_BRAVERY
client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
// Leave
client.user.setHypeSquad(0);

Source

setAccentColor

setAccentColor(color: ColorResolvable): Promise<ClientUser>

Set Accent color Parameters

NameTypeDescription
colorColorResolvableColor to set Default: null.

Returns: Promise<ClientUser>Source

setAboutMe

setAboutMe(bio?: string): Promise<ClientUser>

Set About me Parameters

NameTypeDescription
bio?stringBio to set Default: null.

Returns: Promise<ClientUser>Source

createFriendInvite

async

async createFriendInvite(): Promise<Invite>

Create an invite [Friend Invites] maxAge: 604800 | maxUses: 1 Returns: Promise<Invite>

js
// Options not working
client.user.createFriendInvite();
  .then(console.log)
  .catch(console.error);

Source

getAllFriendInvites

async

async getAllFriendInvites(): Promise<Collection<string, Invite>>

Get all friend invites Returns: Promise<Collection<string, Invite>>Source

revokeAllFriendInvites

revokeAllFriendInvites(): Promise<void>

Revoke all friend invites Returns: Promise<void>Source

setSamsungActivity

async

async setSamsungActivity(packageName: string, type: string): Promise<ClientUser>

Sets Discord Playing status to "Playing on Samsung Galaxy". Only selected gamss from discords database works Parameters

NameTypeDescription
packageNamestringAndroid package name
typestringMust be START, UPDATE, or STOP Default: START.

Returns: Promise<ClientUser>

js
// Set the client user's status
client.user.setSamsungActivity('com.YostarJP.BlueArchive', 'START');
// Update
client.user.setSamsungActivity('com.miHoYo.bh3oversea', 'UPDATE');
// Stop
client.user.setSamsungActivity('com.miHoYo.GenshinImpact', 'STOP');

Source

stopRinging

stopRinging(channel: ChannelResolvable): Promise<void>

Stop ringing Parameters

NameTypeDescription
channelChannelResolvableDMChannel

Returns: Promise<void>Source

fetchBurstCredit

fetchBurstCredit(): Promise<number>

Super Reactions Returns: Promise<number>Source

setGlobalName

setGlobalName(globalName: string): Promise<ClientUser>

Set global display name Parameters

NameTypeDescription
globalNamestringThe new display name

Returns: Promise<ClientUser>Source

setPronouns

setPronouns(pronouns: string): Promise<ClientUser>

Set pronouns Parameters

NameTypeDescription
pronounsstringYour pronouns

Returns: Promise<ClientUser>Source

avatarURL

avatarURL(options?: ImageURLOptions): string

A link to the user's avatar. Parameters

NameTypeDescription
options?ImageURLOptionsOptions for the Image URL Default: {}.

Returns: stringSource

avatarDecorationURL

avatarDecorationURL(): string

A link to the user's avatar decoration. Returns: stringSource

clanBadgeURL

deprecated

clanBadgeURL(): string

A link to the user's guild tag badge. Returns: stringSource

guildTagBadgeURL

guildTagBadgeURL(): string

A link to the user's guild tag badge. Returns: stringSource

displayAvatarURL

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. Parameters

NameTypeDescription
options?ImageURLOptionsOptions for the Image URL Default: {}.

Returns: stringSource

bannerURL

bannerURL(options?: ImageURLOptions): string

A link to the user's banner. This method will throw an error if called before the user is force fetched. See User#banner for more info Parameters

NameTypeDescription
options?ImageURLOptionsOptions for the Image URL Default: {}.

Returns: stringSource

createDM

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

Creates a DM channel between the client and the user. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: false.

Returns: Promise<DMChannel>Source

deleteDM

deleteDM(): Promise<DMChannel>

Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful. Returns: Promise<DMChannel>Source

equals

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. Parameters

NameTypeDescription
userUserUser to compare with

Returns: booleanSource

_equals

private

_equals(user: APIUser): boolean

Compares the user with an API user object Parameters

NameTypeDescription
userAPIUserThe API user object to compare

Returns: booleanSource

fetch

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

Fetches this user. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: true.

Returns: Promise<User>Source

getProfile

getProfile(guildId?: Snowflake): Promise<Object>

Returns a user profile object for a given user ID. This endpoint requires one of the following:

  • The user is a bot
  • The user shares a mutual guild with the current user
  • The user is a friend of the current user
  • The user is a friend suggestion of the current user
  • The user has an outgoing friend request to the current user Parameters
NameTypeDescription
guildId?SnowflakeThe guild ID to get the user's member profile in

Returns: Promise<Object>Source

toString

toString(): string

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

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

Source

setNote

async

async setNote(note?: string | null | undefined): Promise<User>

The function updates the note of a user and returns the updated user. Parameters

NameTypeDescription
note?string | null | undefinedThe note parameter is the new value that you want to set for the note of the
user. It is an optional parameter and its default value is null. Default: null.

Returns: Promise<User> — The setNote method is returning the User object. Source

sendFriendRequest

sendFriendRequest(): Promise<boolean>

Send Friend Request to the user Returns: Promise<boolean>Source

deleteRelationship

deleteRelationship(): Promise<boolean>

Unblock / Unfriend / Cancels a friend request Returns: Promise<boolean>Source

send

send(options: string | MessagePayload | MessageOptions): Promise<Message>

Sends a message to this user. Parameters

NameTypeDescription
optionsstring | MessagePayload | MessageOptionsThe options to provide

Returns: Promise<Message>

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

Source

Unofficial software. Not affiliated with or supported by Discord.