DiscordLua
discorddiscord
v1.2.4
Install

Collection

Class
On this page

Collection is an ordered id-keyed map used for caches. #collection matches :size().

class Module 1.2.4 Source

Constructor

Collection.new(entries)

The class table is callable, so Collection(entries) is the same as .new.

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

Methods

Collection:at()

#

Performs at on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:at(index)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:at(index)

Collection:clear()

#

Performs clear on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:clear()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:clear()

Collection:clone()

#

Performs clone on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:clone()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:clone()

Collection:combine()

#

Performs combine on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:combine(other, collide)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:combine(other, "123")

Collection.combineEntries()

# static

Performs combine entries on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection.combineEntries(entries, combine)

Parameters

NameTypeRequiredBehavior
entries any required Passed through to the implementation as written.
combine any required Passed through to the implementation as written.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
Collection.combineEntries(entries, combine)

Collection:concat()

#

Performs concat on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:concat(...)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:concat(...)

Collection:delete()

#

Permanently delete this resource through REST.

Signature

Collection:delete(key)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:delete(key)

Collection:difference()

#

Performs difference on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:difference(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:difference(other)

Collection:each()

#

Performs each on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:each(fn)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:each(fn)

Collection:ensure()

#

Performs ensure on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:ensure(key, defaultValue)

Parameters

NameTypeRequiredBehavior
key any required Passed through to the implementation as written.
defaultValue any optional Passed through to the implementation as written.

Returns

any.

Example

lua
local discord = require("discord")
-- object is a Collection
object:ensure(key, defaultValue)

Collection:entries()

#

Performs entries on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:entries()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:entries()

Collection:equals()

#

Return whether this Collection refers to the same resource as the argument.

Signature

Collection:equals(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:equals(other)

Collection:every()

#

Performs every on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:every(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:every(predicate)

Collection:filter()

#

Performs filter on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:filter(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:filter(predicate)

Collection:find()

#

Performs find on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:find(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:find(predicate)

Collection:findKey()

#

Performs find key on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:findKey(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:findKey(predicate)

Collection:first()

#

Performs first on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:first()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:first()

Collection:firstKey()

#

Performs first key on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:firstKey()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:firstKey()

Collection:flatMap()

#

Performs flat map on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:flatMap(fn)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:flatMap(fn)

Collection:forEach()

#

Performs for each on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:forEach(fn)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:forEach(fn)

Collection:get()

#

Performs get on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:get(key)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:get(key)

Collection.groupBy()

# static

Performs group by on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection.groupBy(iterable, keyFn)

Parameters

NameTypeRequiredBehavior
iterable any required Passed through to the implementation as written.
keyFn any required Passed through to the implementation as written.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
Collection.groupBy(iterable, keyFn)

Collection:has()

#

Performs has on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:has(key)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:has(key)

Collection:hasAll()

#

Performs has all on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:hasAll(...)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:hasAll(...)

Collection:hasAny()

#

Performs has any on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:hasAny(...)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:hasAny(...)

Collection:intersect()

#

Predicate that returns whether this Collection matches intersect. Use it to branch before calling type-specific methods.

Signature

Collection:intersect(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:intersect(other)

Collection:intersection()

#

Predicate that returns whether this Collection matches intersection. Use it to branch before calling type-specific methods.

Signature

Collection:intersection(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:intersection(other)

Collection:keyArray()

#

Performs key array on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:keyArray()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:keyArray()

Collection:keyAt()

#

Performs key at on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:keyAt(index)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:keyAt(index)

Collection:keys()

#

Performs keys on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:keys()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:keys()

Collection:last()

#

Performs last on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:last()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:last()

Collection:lastKey()

#

Performs last key on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:lastKey()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:lastKey()

Collection:map()

#

Performs map on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:map(mapper)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:map(mapper)

Collection:mapValues()

#

Performs map values on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:mapValues(mapper)

Parameters

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

Returns

any.

Example

lua
local discord = require("discord")
-- object is a Collection
object:mapValues(mapper)

Collection:merge()

#

Performs merge on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:merge(other, whenInSelf, whenInOther, whenInBoth)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:merge(other, whenInSelf, whenInOther, whenInBoth)

Collection:partition()

#

Performs partition on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:partition(predicate)

Parameters

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

Returns

any.

Example

lua
local discord = require("discord")
-- object is a Collection
object:partition(predicate)

Collection:random()

#

Performs random on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:random()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:random()

Collection:randomKey()

#

Performs random key on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:randomKey()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:randomKey()

Collection:reduce()

#

Performs reduce on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:reduce(reducer, initial)

Parameters

NameTypeRequiredBehavior
reducer any required Passed through to the implementation as written.
initial any required Passed through to the implementation as written.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:reduce(reducer, initial)

Collection:reverse()

#

Performs reverse on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:reverse()

Parameters

No parameters.

Returns

any.

Example

lua
local discord = require("discord")
-- object is a Collection
object:reverse()

Collection:set()

#

Performs set on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:set(key, value)

Parameters

NameTypeRequiredBehavior
key any required Passed through to the implementation as written.
value any required Passed through to the implementation as written.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:set(key, value)

Collection:size()

#

Performs size on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:size()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:size()

Collection:some()

#

Performs some on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:some(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:some(predicate)

Collection:sort()

#

Performs sort on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:sort(compare)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:sort(compare)

Collection:subtract()

#

Performs subtract on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:subtract(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:subtract(other)

Collection:sweep()

#

Performs sweep on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:sweep(predicate)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:sweep(predicate)

Collection:tap()

#

Performs tap on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:tap(fn)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:tap(fn)

Collection:toArray()

#

Performs to array on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:toArray()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:toArray()

Collection:toJSON()

#

Serialize this Collection into a Lua table suitable for REST or debugging.

Signature

Collection:toJSON()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:toJSON()

Collection:union()

#

Performs union on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:union(other)

Parameters

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

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:union(other)

Collection:values()

#

Performs values on this Collection. Call it from bot code when you need that operation on the current object.

Signature

Collection:values()

Parameters

No parameters.

Returns

Collection — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Collection
object:values()

Static members

  • Collection.LimitedCollection

Examples

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

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

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc