DiscordLua
discorddiscord
v1.2.4
Install

User

Class
On 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.

class Module 1.2.4 Source

Properties

User.accentColor

# readonly
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.

User.avatar

# readonly
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.

User.avatarDecoration

# readonly
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.

User.avatarDecorationData

# readonly
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.

User.banner

# readonly
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.

User.bot

# readonly
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.

User.client

# readonly
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.

User.collectibles

# readonly
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.

User.discriminator

# readonly
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.

User.flags

# readonly
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.

User.globalName

# readonly
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.

User.id

# readonly
Name
id
Type
any
Access
readonly
Description
Snowflake id of this User.
Availability
Populated from the Gateway/REST payload or constructor for this User.

User.partial

# readonly
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.

User.primaryGuild

# readonly
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.

User.publicFlags

# readonly
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.

User.raw

# readonly
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.

User.system

# readonly
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.

User.username

# readonly
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

User — the same instance, for chaining.

Example

lua
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

lua
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

lua
local discord = require("discord")
-- object is a User
object:defaultAvatarURL()

User:deleteDM()

#

Permanently delete DM through REST.

Signature

User:deleteDM(callback)

Parameters

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

User — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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

NameTypeRequiredBehavior
other any required Passed through to the implementation as written.

Returns

any.

Example

lua
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

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

User — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

User — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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

lua
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.

ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc