Skip to content
SinisterRectus edited this page Nov 19, 2023 · 20 revisions

extends Snowflake

Represents a single user of Discord, either a human or a bot, outside of any specific guild's context.

Instances of this class should not be constructed by users.

Properties Inherited From Snowflake

Name Type Description
client Client A shortcut to the client object to which this container is visible.
createdAt number The Unix time in seconds at which this object was created by Discord. Additional decimal points may be present, though only the first 3 (milliseconds) should be considered accurate. Equivalent to Date.parseSnowflake(Snowflake.id).
id string The Snowflake ID that can be used to identify the object. This is guaranteed to be unique except in cases where an object shares the ID of its parent.
parent Container/Client The parent object of to which this container is a child. For example, the parent of a role is the guild in which the role exists.
timestamp string The date and time at which this object was created by Discord, represented as an ISO 8601 string plus microseconds when available. Equivalent to Date.fromSnowflake(Snowflake.id):toISO().

Properties

Name Type Description
avatar string/nil The hash for the user's custom avatar, if one is set.
avatarURL string Equivalent to the result of calling User:getAvatarURL().
bot boolean Whether this user is a bot.
defaultAvatar number The user's default avatar. See the defaultAvatar enumeration for a human-readable representation.
defaultAvatarURL string Equivalent to the result of calling User:getDefaultAvatarURL().
discriminator number The discriminator of the user. This is a string that is used to discriminate the user from other users with the same username. Note that this will be "0" for users with unique usernames.
globalName string/nil The global display name of the user. If set, this has priority over the a username in displays, but not over a guild nickname.
mentionString string A string that, when included in a message content, may resolve as user notification in the official Discord client.
mutualGuilds FilteredIterable A iterable cache of all guilds where this user shares a membership with the current user. The guild must be cached on the current client and the user's member object must be cached in that guild in order for it to appear here.
name string Equivalent to User.globalName or User.username.
tag string The user's username if unique or username and discriminator concatenated by an #.
username string The name of the user. This should be between 2 and 32 characters in length.

Methods Inherited From Snowflake

__eq()

Defines the behavior of the == operator. Allows containers to be directly compared according to their type and __hash return values.

Returns: boolean


__hash()

Returns Snowflake.id

Returns: string


__tostring()

Defines the behavior of the tostring function. All containers follow the format ClassName: hash.

Returns: string


getDate()

Returns a unique Date object that represents when the object was created by Discord. Equivalent to Date.fromSnowflake(Snowflake.id)

This method only operates on data in memory.

Returns: Date


Methods

getAvatarURL(size, ext)

Parameter Type Optional
size number
ext string

Returns a URL that can be used to view the user's full avatar. If provided, the size must be a power of 2 while the extension must be a valid image format. If the user does not have a custom avatar, the default URL is returned.

This method only operates on data in memory.

Returns: string


getDefaultAvatarURL(size)

Parameter Type Optional
size number

Returns a URL that can be used to view the user's default avatar.

This method only operates on data in memory.

Returns: string


getPrivateChannel()

Returns a private channel that can be used to communicate with the user. If the channel is not cached an HTTP request is made to open one.

This method always makes an HTTP request.

Returns: PrivateChannel


send(content)

Parameter Type
content string/table

Equivalent to User:getPrivateChannel():send(content)

This method always makes an HTTP request.

Returns: Message


sendf(content)

Parameter Type
content string

Equivalent to User:getPrivateChannel():sendf(content)

This method always makes an HTTP request.

Returns: Message


Clone this wiki locally