Skip to main content
A User is a Discord account, the same in every server. You get one as the user of a command, as message.author, as member.user and as the user of the memberLeave event. For what is specific to one server (nickname, roles, permissions), see GuildMember.
How your functions receive a user is in Commands and Events. What a private message can hold is in Messages.
Sending a private message fails when the user has closed their private messages or shares no server with the bot. Catch the error when that is fine for you: see Errors.

Properties

Snowflake
The unique id Discord gave it.
Date
When it was created: a Discord id contains its creation date.
string
The unique name of the account (@name).
string | null
The name shown in Discord, when the user chose one.
string
The name to show: the display name, or else the username.
string
"0" for users on the current username system.
boolean
Whether the account is a bot.
boolean
Whether the account is an official Discord system account.
string | null
The hash of the avatar; use avatarURL() to get the image.
string | null
The hash of the banner; use bannerURL() to get the image.
number | null
The banner color, as a number (0xff0000).
Locale | null
Only known for the bot itself. See Locale.
UserFlagName[]
The public badges of the account, by name. See UserFlagName.

Helpers

These read what the bot remembers: they never send a request.

avatarURL()

The URL of the avatar; of the default one when none is set. See ImageOptions.

bannerURL()

The URL of the banner, when one is set. See ImageOptions.

toString()

<@id>: mentions the user when put in a message.

toJSON()

The data of Discord as a plain object, with camelCase names.

Reading from Discord

fetch()

Asks Discord for the latest data of this user.

Actions

createDM()

Opens the private conversation with this user. See DMChannel. Discord documentation

send()

Sends a private message to this user. See MessageInput.

Types

UserFlagName

The name of a public badge, as flags lists them: one of the keys of UserFlags. Discord documentation ImageOptions is in Helpers.