User

class User()

A Discord account returned in an event payload or REST response. The object is a snapshot. Call User.fetch when current profile data matters.

exported from lib.weeble.d

Implements:

Properties

User.accentColor

type: readonly number | null | undefined

The user’s accent color as a 24-bit RGB integer, or null.

User.avatar

type: readonly string | null | undefined

Hash of the user’s avatar, or null if using the default avatar.

User.banner

type: readonly string | null | undefined

Hash of the user’s banner, or null if no banner is set.

User.bot

type: readonly boolean | null | undefined

Indicates whether this user is a bot. undefined when omitted, null if Discord sent null.

User.createdAt

type: readonly Date

When this Discord account was created, decoded from the user snowflake.

User.discriminator

type: readonly string | undefined

The user’s four-digit discriminator (e.g. "1234"). undefined when omitted; not invented as "0".

User.displayName

type: readonly string

The name best suited for display in user-facing output. Returns the global display name when set, otherwise the username.

User.globalName

type: readonly string | null | undefined

The user’s global display name, or null if not set.

User.id

type: readonly string

User ID.

User.primaryGuild

type: readonly UserPrimaryGuild | null | undefined

The user’s displayed guild identity, or null when none is selected.

User.publicFlags

type: readonly number | null | undefined

Public Discord user flags bitfield, or null when Discord omitted it.

User.username

type: readonly string

The user’s display name (not globally unique).

Methods

User.displayAvatarURL(options: { format?: “png” | “jpg” | “webp” | “gif”; size?: number; }) string

Get the CDN URL for the user’s avatar.

Parameters:
  • options — – Optional size and image format for the avatar.

Returns:

The CDN URL string.

async User.fetch() Promise<User>

Refetch the latest user data from Discord.

Returns:

The updated user object.

User.getTag() string

Returns username#discriminator. For migrated accounts this is usually username#0.

Returns:

The tag string.

User.toMention() string

Returns <@userId> mention syntax.

Returns:

The mention string for this user.