DiscordLua
discorddiscord
v1.2.4
Install

Collector

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

collector Module 1.2.4 Source

Constructor

Collector.new(client, options)

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

NameTypeRequiredBehavior
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.
lua
local discord = require("discord")
local object = discord.Collector({}, {})

Properties

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

Collector.collected

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

Collector.endReason

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

Collector.ended

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

Collector.filter

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

Collector.idle

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

Collector.lastCollectedTimestamp

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

Collector.max

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

Collector.options

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

Collector.time

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

lua
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

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

Returns

Collector — the same instance, for chaining.

Example

lua
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

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

Returns

Collector — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

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

Returns

Collector — the same instance, for chaining.

Example

lua
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

lua
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

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

Returns

Collector — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
reason string optional Audit-log reason sent as X-Audit-Log-Reason on REST mutations.

Returns

Collector — the same instance, for chaining.

Example

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

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

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

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

lua
object:on("ignore", function(...)
    -- handler arguments match the DiscordLua emit for this event
end)

Examples

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

InteractionCollector · MessageCollector · ReactionCollector

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc