Skip to content

User

Package: @erinjs/core

Represents a user (or bot) on erin.js.

Constructor

NameTypeOptionalDescription
clientClientNo
dataAPIUserPartialNoAPI user from message author, GET /users/{id}, or GET /users/@me

Properties

NameTypeReadonlyOptionalDescription
avatarstring | nullNoNo
avatarColornumber | nullNoNoRGB avatar color (e.g. 7577782). Null if not set.
bannerstring | nullNoNoBanner hash (from profile, member, or invite context). Null when not available.
botbooleanYesNo
clientClientYesNo
discriminatorstringNoNo
flagsnumber | nullNoNoPublic flags bitfield. Null if not set.
globalNamestring | nullNoNo
idstringYesNo
systembooleanYesNoWhether this is an official system user.
usernamestringNoNo

Methods

avatarURL()

Get the URL for this user's avatar. Auto-detects animated avatars (hash starting with a_) and uses gif extension.

Returns: string | null

Parameters:

NameTypeOptionalDescription
options{ size?: number; extension?: string; }YesOptional size and extension (default: png, or gif for animated)

bannerURL()

Get the URL for this user's banner. Returns null if the user has no banner (only available when fetched from profile/member context).

Returns: string | null

Parameters:

NameTypeOptionalDescription
options{ size?: number; extension?: string; }Yes

createDM() async

Create or get a DM channel with this user. Returns the DM channel; use {@link DMChannel.send} to send messages.

Returns: Promise<DMChannel>

Parameters:

None


displayAvatarURL()

Get the avatar URL, or the default avatar if none set (erin.js: fluxerstatic.com).

Returns: string

Parameters:

NameTypeOptionalDescription
options{ size?: number; extension?: string; }Yes

send() async

Send a DM to this user. Convenience method that creates the DM channel and sends the message.

Returns: Promise<Message>

Parameters:

NameTypeOptionalDescription
optionsMessageSendOptionsNo

toString()

Returns a mention string (e.g. <@123456>).

Returns: string

Parameters:

None

Released under the Apache-2.0 License.