Collector
collectorOn this page
Collector is a DiscordLua collector representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Constructor
Collector.new(client, options) The class table is callable, so Collector(client, options) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
local discord = require("discord")
local object = discord.Collector({}, {})Properties
- 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 Collector.
- Name
collected- Type
- Collection
- Access
- readonly
- Description
- Instance field
Collector.collected. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Related
- Collection
- Name
endReason- Type
any- Access
- readonly
- Description
- Instance field
Collector.endReason. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
ended- Type
any- Access
- readonly
- Description
- Instance field
Collector.ended. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
filter- Type
any- Access
- readonly
- Description
- Instance field
Collector.filter. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
idle- Type
any- Access
- readonly
- Description
- Instance field
Collector.idle. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
lastCollectedTimestamp- Type
any- Access
- readonly
- Description
- Instance field
Collector.lastCollectedTimestamp. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
max- Type
any- Access
- readonly
- Description
- Instance field
Collector.max. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
options- Type
any- Access
- readonly
- Description
- Instance field
Collector.options. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
- Name
time- Type
any- Access
- readonly
- Description
- Instance field
Collector.time. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Collector.
Methods
Collector:checkEnd()
#Performs check end on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:checkEnd() Parameters
No parameters.
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:checkEnd()Collector:collect()
#Performs collect on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:collect(item) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
item |
any |
required | Passed through to the implementation as written. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:collect(item)Collector:dispose()
#Performs dispose on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:dispose(item) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
item |
any |
required | Passed through to the implementation as written. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:dispose(item)Collector:handleCollect()
#Performs handle collect on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:handleCollect(item, key) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
item |
any |
required | Passed through to the implementation as written. |
key |
any |
required | Passed through to the implementation as written. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:handleCollect(item, key)Collector:handleDispose()
#Performs handle dispose on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:handleDispose(item) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
item |
any |
required | Passed through to the implementation as written. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:handleDispose(item)Collector:lastCollectedAt()
#Performs last collected at on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:lastCollectedAt() Parameters
No parameters.
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:lastCollectedAt()Collector:next()
#Performs next on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:next(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:next(function(err, result)
if err then error(err) end
end)Collector:on()
#Performs on on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:on(event, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
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
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:on(event, function(err, result)
if err then error(err) end
end)Collector:resetTimer()
#Performs reset timer on this Collector. Call it from bot code when you need that operation on the current object.
Signature
Collector:resetTimer(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:resetTimer({})Collector:stop()
#Stop the native event loop so the process can exit cleanly.
Signature
Collector:stop(reason) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
reason |
string |
optional | Audit-log reason sent as X-Audit-Log-Reason on REST mutations. |
Returns
Collector — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Collector
object:stop(reason)Events
collect
#Emitted by Collector when the corresponding Gateway or local lifecycle update occurs. Listen with :on("collect", handler).
object:on("collect", function(...)
-- handler arguments match the DiscordLua emit for this event
end)dispose
#Emitted by Collector when the corresponding Gateway or local lifecycle update occurs. Listen with :on("dispose", handler).
object:on("dispose", function(...)
-- handler arguments match the DiscordLua emit for this event
end)end
#Emitted by Collector when the corresponding Gateway or local lifecycle update occurs. Listen with :on("end", handler).
object:on("end", function(...)
-- handler arguments match the DiscordLua emit for this event
end)ignore
#Emitted by Collector when the corresponding Gateway or local lifecycle update occurs. Listen with :on("ignore", handler).
object:on("ignore", function(...)
-- handler arguments match the DiscordLua emit for this event
end)Examples
local discord = require("discord")
local object = discord.Collector({})Related APIs
InteractionCollector · MessageCollector · ReactionCollector
Version: discord 1.2.4 · runtime 1.0.0