DiscordLua
discorddiscord
v1.2.4
Install

UserManager

Manager
On this page

UserManager is the cache and REST facade for User objects owned by the parent. Typical calls are fetch, create, edit, delete, resolve, and resolveId.

manager Module 1.2.4 Source

Constructor

UserManager.new(client)

The class table is callable, so UserManager(client) is the same as .new.

NameTypeRequiredBehavior
client any required Passed through to the implementation as written.
lua
local discord = require("discord")
local object = discord.UserManager({})

Methods

UserManager:createDM()

#

Create DM through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.

Signature

UserManager:createDM(user, callback)

Parameters

NameTypeRequiredBehavior
user any required Passed through to the implementation as written.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

UserManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a UserManager
object:createDM(user, function(err, result)
    if err then error(err) end
end)

UserManager:deleteDM()

#

Permanently delete DM through REST.

Signature

UserManager:deleteDM(user, callback)

Parameters

NameTypeRequiredBehavior
user any required Passed through to the implementation as written.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

UserManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a UserManager
object:deleteDM(user, function(err, result)
    if err then error(err) end
end)

UserManager:fetch()

#

Request a fresh copy of this resource from REST and update the cache.

Signature

UserManager:fetch(id, callback)

Parameters

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

Returns

UserManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a UserManager
object:fetch("123", function(err, result)
    if err then error(err) end
end)

UserManager:fetchFlags()

#

Fetch Flags from REST and update the local cache when the request succeeds.

Signature

UserManager:fetchFlags(user, callback)

Parameters

NameTypeRequiredBehavior
user any required Passed through to the implementation as written.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

UserManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a UserManager
object:fetchFlags(user, function(err, result)
    if err then error(err) end
end)

UserManager:send()

#

Send a message, payload, or packet using this object.

Signature

UserManager:send(user, contentOrOptions, callback)

Parameters

NameTypeRequiredBehavior
user any required Passed through to the implementation as written.
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

any.

Example

lua
local discord = require("discord")
-- object is a UserManager
object:send(user, "Hello", function(err, result)
    if err then error(err) end
end)

Examples

lua
local discord = require("discord")
local object = discord.UserManager({})

ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CachedManager · CategoryChannelChildManager

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc