UserManager
ManagerOn 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.
Constructor
UserManager.new(client) The class table is callable, so UserManager(client) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
local discord = require("discord")
-- object is a UserManager
object:send(user, "Hello", function(err, result)
if err then error(err) end
end)Examples
local discord = require("discord")
local object = discord.UserManager({})Related APIs
ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CachedManager · CategoryChannelChildManager
Version: discord 1.2.4 · runtime 1.0.0