User
ClassOn this page
User is a Discord user. Read identity fields and open a DM through the user manager when the bot needs a private channel.
Properties
- Name
accentColor- Type
any- Access
- readonly
- Description
- Instance field
User.accentColor. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
avatar- Type
any- Access
- readonly
- Description
- Instance field
User.avatar. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
avatarDecoration- Type
any- Access
- readonly
- Description
- Instance field
User.avatarDecoration. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
avatarDecorationData- Type
any- Access
- readonly
- Description
- Instance field
User.avatarDecorationData. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
banner- Type
any- Access
- readonly
- Description
- Instance field
User.banner. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
bot- Type
any- Access
- readonly
- Description
- Instance field
User.bot. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
client- Type
any- Access
- readonly
- Description
- Owning Client instance used for REST, cache, and event dispatch.
- Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
collectibles- Type
any- Access
- readonly
- Description
- Instance field
User.collectibles. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
discriminator- Type
any- Access
- readonly
- Description
- Instance field
User.discriminator. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
flags- Type
any- Access
- readonly
- Description
- Instance field
User.flags. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
globalName- Type
any- Access
- readonly
- Description
- Instance field
User.globalName. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this User.
- Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
partial- Type
any- Access
- readonly
- Description
- Instance field
User.partial. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
primaryGuild- Type
any- Access
- readonly
- Description
- Instance field
User.primaryGuild. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
publicFlags- Type
any- Access
- readonly
- Description
- Instance field
User.publicFlags. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
raw- Type
any- Access
- readonly
- Description
- Instance field
User.raw. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
system- Type
any- Access
- readonly
- Description
- Instance field
User.system. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
- Name
username- Type
any- Access
- readonly
- Description
- Instance field
User.username. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this User.
Methods
User:avatarDecorationURL()
#Performs avatar decoration url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:avatarDecorationURL() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:avatarDecorationURL()User:avatarURL()
#Performs avatar url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:avatarURL(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:avatarURL({})User:bannerURL()
#Performs banner url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:bannerURL(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:bannerURL({})User:createdAt()
#Create dAt through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
User:createdAt() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:createdAt()User:createDM()
#Create DM through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
User:createDM(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:createDM(function(err, result)
if err then error(err) end
end)User:createdTimestamp()
#Create dTimestamp through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
User:createdTimestamp() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:createdTimestamp()User:defaultAvatarURL()
#Performs default avatar url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:defaultAvatarURL() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:defaultAvatarURL()User:deleteDM()
#Permanently delete DM through REST.
Signature
User:deleteDM(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:deleteDM(function(err, result)
if err then error(err) end
end)User:displayAvatarURL()
#Performs display avatar url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:displayAvatarURL(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:displayAvatarURL({})User:displayName()
#Performs display name on this User. Call it from bot code when you need that operation on the current object.
Signature
User:displayName() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:displayName()User:dmChannel()
#Performs dm channel on this User. Call it from bot code when you need that operation on the current object.
Signature
User:dmChannel() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:dmChannel()User:equals()
#Return whether this User refers to the same resource as the argument.
Signature
User:equals(other) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
other |
any |
required | Passed through to the implementation as written. |
Returns
any.
Example
local discord = require("discord")
-- object is a User
object:equals(other)User:fetch()
#Request a fresh copy of this resource from REST and update the cache.
Signature
User:fetch(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:fetch(function(err, result)
if err then error(err) end
end)User:fetchFlags()
#Fetch Flags from REST and update the local cache when the request succeeds.
Signature
User:fetchFlags(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:fetchFlags(function(err, result)
if err then error(err) end
end)User:guildTagBadgeURL()
#Performs guild tag badge url on this User. Call it from bot code when you need that operation on the current object.
Signature
User:guildTagBadgeURL(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:guildTagBadgeURL({})User:hexAccentColor()
#Performs hex accent color on this User. Call it from bot code when you need that operation on the current object.
Signature
User:hexAccentColor() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:hexAccentColor()User:send()
#Send a message, payload, or packet using this object.
Signature
User:send(contentOrOptions, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
contentOrOptions |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:send("Hello", function(err, result)
if err then error(err) end
end)User:tag()
#Performs tag on this User. Call it from bot code when you need that operation on the current object.
Signature
User:tag() Parameters
No parameters.
Returns
User — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a User
object:tag()User:toJSON()
#Serialize this User into a Lua table suitable for REST or debugging.
Signature
User:toJSON() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a User
object:toJSON()User:toString()
#function toString() { [native code] }
Signature
User:toString() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a User
object:toString()Examples
Obtain this object from a manager, wrap helper, or event payload — it is not constructed directly in typical bot code.
Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0