Class: StoreRegistry
A strict-typed store registry. This is available in container.
Since
2.1.0
Example
// Adding new stores
// Register the store:
container.stores.register(new RouteStore());
// Augment Sapphire to add the new store, in case of a JavaScript
// project, this can be moved to an `Augments.d.ts` (or any other name)
// file somewhere:
declare module '@sapphire/pieces' {
export interface StoreRegistryEntries {
routes: RouteStore;
}
}
Hierarchy
Collection
<Key
,Value
>↳
StoreRegistry
Constructors
constructor
• new StoreRegistry(entries?
)
Parameters
Name | Type |
---|---|
entries? | null | readonly readonly [keyof StoreRegistryEntries , Value ][] |
Inherited from
Collection<Key, Value>.constructor
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:51
• new StoreRegistry(iterable?
)
Parameters
Name | Type |
---|---|
iterable? | null | Iterable <readonly [keyof StoreRegistryEntries , Value ]> |
Inherited from
Collection<Key, Value>.constructor
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:159
Properties
[toStringTag]
• Readonly
[toStringTag]: string
Inherited from
Collection.[toStringTag]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137
constructor
• constructor: CollectionConstructor
Inherited from
Collection.constructor
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:21
size
• Readonly
size: number
Inherited from
Collection.size
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:46
[species]
▪ Static
Readonly
[species]: MapConstructor
Inherited from
Collection.[species]
Defined in
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319
Methods
[iterator]
▸ [iterator](): IterableIterator
<[keyof StoreRegistryEntries
, Value
]>
Returns an iterable of entries in the map.
Returns
IterableIterator
<[keyof StoreRegistryEntries
, Value
]>
Inherited from
Collection.[iterator]
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
at
▸ at(index
): undefined
| Value
Identical to Array.at(). Returns the item at a given index, allowing for positive and negative integers. Negative integers count back from the last item in the collection.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the element to obtain |
Returns
undefined
| Value
Inherited from
Collection.at
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:98
clear
▸ clear(): void
Returns
void
Inherited from
Collection.clear
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:21
clone
▸ clone(): Collection
<keyof StoreRegistryEntries
, Value
>
Creates an identical shallow copy of this collection.
Example
const newColl = someColl.clone();
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.clone
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:328
concat
▸ concat(...collections
): Collection
<keyof StoreRegistryEntries
, Value
>
Combines this collection with others into a new collection. None of the source collections are modified.
Example
const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
Parameters
Name | Type | Description |
---|---|---|
...collections | ReadonlyCollection <keyof StoreRegistryEntries , Value >[] | Collections to merge |
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.concat
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:338
delete
▸ delete(key
): boolean
Parameters
Name | Type |
---|---|
key | keyof StoreRegistryEntries |
Returns
boolean
true if an element in the Map existed and has been removed, or false if the element does not exist.
Inherited from
Collection.delete
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:25
deregister
▸ deregister<T
>(store
): StoreRegistry
Deregisters a store.
Since
2.1.0
Type parameters
Name | Type |
---|---|
T | extends Piece <PieceOptions , T > |
Parameters
Name | Type | Description |
---|---|---|
store | Store <T > | The store to deregister. |
Returns
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:556
difference
▸ difference<T
>(other
): Collection
<keyof StoreRegistryEntries
, Value
| T
>
The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyCollection <keyof StoreRegistryEntries , T > | The other Collection to filter against |
Returns
Collection
<keyof StoreRegistryEntries
, Value
| T
>
Inherited from
Collection.difference
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:378
each
▸ each(fn
): StoreRegistry
Identical to Map.forEach(), but returns the collection instead of undefined.
Example
collection
.each(user => console.log(user.username))
.filter(user => user.bot)
.each(user => console.log(user.username));
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => void | Function to execute for each element |
Returns
Inherited from
Collection.each
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:303
▸ each<T
>(fn
, thisArg
): StoreRegistry
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (this : T , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => void |
thisArg | T |
Returns
Inherited from
Collection.each
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:304
ensure
▸ ensure(key
, defaultValueGenerator
): Value
Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
Example
collection.ensure(guildId, () => defaultGuildConfig);
Parameters
Name | Type | Description |
---|---|---|
key | keyof StoreRegistryEntries | The key to get if it exists, or set otherwise |
defaultValueGenerator | (key : keyof StoreRegistryEntries , collection : StoreRegistry ) => Value | A function that generates the default value |
Returns
Value
Inherited from
Collection.ensure
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:41
entries
▸ entries(): IterableIterator
<[keyof StoreRegistryEntries
, Value
]>
Returns an iterable of key, value pairs for every entry in the map.
Returns
IterableIterator
<[keyof StoreRegistryEntries
, Value
]>
Inherited from
Collection.entries
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:124
equals
▸ equals(collection
): boolean
Checks if this collection shares identical items with another. This is different to checking for equality using equal-signs, because the collections may be different objects, but contain the same data.
Parameters
Name | Type | Description |
---|---|---|
collection | ReadonlyCollection <keyof StoreRegistryEntries , Value > | Collection to compare with |
Returns
boolean
Whether the collections have identical contents
Inherited from
Collection.equals
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:347
every
▸ every<K2
>(fn
): this is Collection<K2, Value>
Checks if all items passes a test. Identical in behavior to Array.every().
Example
collection.every(user => !user.bot);
Type parameters
Name | Type |
---|---|
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 | Function used to test (should return a boolean) |
Returns
this is Collection<K2, Value>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:269
▸ every<V2
>(fn
): this is Collection<keyof StoreRegistryEntries, V2>
Type parameters
Name | Type |
---|---|
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
Returns
this is Collection<keyof StoreRegistryEntries, V2>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:270
▸ every(fn
): boolean
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
Returns
boolean
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:271
▸ every<This
, K2
>(fn
, thisArg
): this is Collection<K2, Value>
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 |
thisArg | This |
Returns
this is Collection<K2, Value>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:272
▸ every<This
, V2
>(fn
, thisArg
): this is Collection<keyof StoreRegistryEntries, V2>
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
thisArg | This |
Returns
this is Collection<keyof StoreRegistryEntries, V2>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:273
▸ every<This
>(fn
, thisArg
): boolean
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | This |
Returns
boolean
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:274
filter
▸ filter<K2
>(fn
): Collection
<K2
, Value
>
Identical to Array.filter(), but returns a Collection instead of an Array.
Example
collection.filter(user => user.username === 'Bob');
Type parameters
Name | Type |
---|---|
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 | The function to test with (should return boolean) |
Returns
Collection
<K2
, Value
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:183
▸ filter<V2
>(fn
): Collection
<keyof StoreRegistryEntries
, V2
>
Type parameters
Name | Type |
---|---|
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
Returns
Collection
<keyof StoreRegistryEntries
, V2
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:184
▸ filter(fn
): Collection
<keyof StoreRegistryEntries
, Value
>
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:185
▸ filter<This
, K2
>(fn
, thisArg
): Collection
<K2
, Value
>
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 |
thisArg | This |
Returns
Collection
<K2
, Value
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:186
▸ filter<This
, V2
>(fn
, thisArg
): Collection
<keyof StoreRegistryEntries
, V2
>
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
thisArg | This |
Returns
Collection
<keyof StoreRegistryEntries
, V2
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:187
▸ filter<This
>(fn
, thisArg
): Collection
<keyof StoreRegistryEntries
, Value
>
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | This |
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:188
find
▸ find<V2
>(fn
): undefined
| V2
Searches for a single item where the given function returns a truthy value. This behaves like
Array.find().
All collections used in Discord.js are mapped using their id
property, and if you want to find by id you
should use the get
method. See
MDN for details.
Example
collection.find(user => user.username === 'Bob');
Type parameters
Name | Type |
---|---|
V2 | extends Value |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 | The function to test with (should return boolean) |
Returns
undefined
| V2
Inherited from
Collection.find
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:142
▸ find(fn
): undefined
| Value
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
Returns
undefined
| Value
Inherited from
Collection.find
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:143
▸ find<This
, V2
>(fn
, thisArg
): undefined
| V2
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
thisArg | This |
Returns
undefined
| V2
Inherited from
Collection.find
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:144
▸ find<This
>(fn
, thisArg
): undefined
| Value
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | This |
Returns
undefined
| Value
Inherited from
Collection.find
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:145
findKey
▸ findKey<K2
>(fn
): undefined
| K2
Searches for the key of a single item where the given function returns a truthy value. This behaves like Array.findIndex(), but returns the key rather than the positional index.
Example
collection.findKey(user => user.username === 'Bob');
Type parameters
Name | Type |
---|---|
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 | The function to test with (should return boolean) |
Returns
undefined
| K2
Inherited from
Collection.findKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:158
▸ findKey(fn
): undefined
| keyof StoreRegistryEntries
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
Returns
undefined
| keyof StoreRegistryEntries
Inherited from
Collection.findKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:159
▸ findKey<This
, K2
>(fn
, thisArg
): undefined
| K2
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 |
thisArg | This |
Returns
undefined
| K2
Inherited from
Collection.findKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:160
▸ findKey<This
>(fn
, thisArg
): undefined
| keyof StoreRegistryEntries
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | This |
Returns
undefined
| keyof StoreRegistryEntries
Inherited from
Collection.findKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:161
first
▸ first(): undefined
| Value
Obtains the first value(s) in this collection.
Returns
undefined
| Value
A single value if no amount is provided or an array of values, starting from the end if amount is negative
Inherited from
Collection.first
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:62
▸ first(amount
): Value
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
Value
[]
Inherited from
Collection.first
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:63
firstKey
▸ firstKey(): undefined
| keyof StoreRegistryEntries
Obtains the first key(s) in this collection.
Returns
undefined
| keyof StoreRegistryEntries
A single key if no amount is provided or an array of keys, starting from the end if amount is negative
Inherited from
Collection.firstKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:71
▸ firstKey(amount
): keyof StoreRegistryEntries
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
keyof StoreRegistryEntries
[]
Inherited from
Collection.firstKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:72
flatMap
▸ flatMap<T
>(fn
): Collection
<keyof StoreRegistryEntries
, T
>
Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to Array.flatMap().
Example
collection.flatMap(guild => guild.members.cache);
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => Collection <keyof StoreRegistryEntries , T > | Function that produces a new Collection |
Returns
Collection
<keyof StoreRegistryEntries
, T
>
Inherited from
Collection.flatMap
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:217
▸ flatMap<T
, This
>(fn
, thisArg
): Collection
<keyof StoreRegistryEntries
, T
>
Type parameters
Name |
---|
T |
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => Collection <keyof StoreRegistryEntries , T > |
thisArg | This |
Returns
Collection
<keyof StoreRegistryEntries
, T
>
Inherited from
Collection.flatMap
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:218
forEach
▸ forEach(callbackfn
, thisArg?
): void
Executes a provided function once per each key/value pair in the Map, in insertion order.
Parameters
Name | Type |
---|---|
callbackfn | (value : Value , key : keyof StoreRegistryEntries , map : Map <keyof StoreRegistryEntries , Value >) => void |
thisArg? | any |
Returns
void
Inherited from
Collection.forEach
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:29
get
▸ get<K
>(key
): StoreRegistryEntries
[K
]
Type parameters
Name | Type |
---|---|
K | extends keyof StoreRegistryEntries |
Parameters
Name | Type |
---|---|
key | K |
Returns
Inherited from
Collection.get
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:559
▸ get(key
): undefined
Parameters
Name | Type |
---|---|
key | string |
Returns
undefined
Inherited from
Collection.get
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:560
has
▸ has(key
): true
Parameters
Name | Type |
---|---|
key | keyof StoreRegistryEntries |
Returns
true
Inherited from
Collection.has
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:561
▸ has(key
): false
Parameters
Name | Type |
---|---|
key | string |
Returns
false
Inherited from
Collection.has
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:562
hasAll
▸ hasAll(...keys
): boolean
Checks if all of the elements exist in the collection.
Parameters
Name | Type | Description |
---|---|---|
...keys | keyof StoreRegistryEntries [] | The keys of the elements to check for |
Returns
boolean
true
if all of the elements exist, false
if at least one does not exist.
Inherited from
Collection.hasAll
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:48
hasAny
▸ hasAny(...keys
): boolean
Checks if any of the elements exist in the collection.
Parameters
Name | Type | Description |
---|---|---|
...keys | keyof StoreRegistryEntries [] | The keys of the elements to check for |
Returns
boolean
true
if any of the elements exist, false
if none exist.
Inherited from
Collection.hasAny
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:55
intersect
▸ intersect<T
>(other
): Collection
<keyof StoreRegistryEntries
, T
>
The intersect method returns a new structure containing items where the keys and values are present in both original structures.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyCollection <keyof StoreRegistryEntries , T > | The other Collection to filter against |
Returns
Collection
<keyof StoreRegistryEntries
, T
>
Inherited from
Collection.intersect
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:366
keyAt
▸ keyAt(index
): undefined
| keyof StoreRegistryEntries
Identical to Array.at(). Returns the key at a given index, allowing for positive and negative integers. Negative integers count back from the last item in the collection.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the key to obtain |
Returns
undefined
| keyof StoreRegistryEntries
Inherited from
Collection.keyAt
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:106
keys
▸ keys(): IterableIterator
<keyof StoreRegistryEntries
>
Returns an iterable of keys in the map
Returns
IterableIterator
<keyof StoreRegistryEntries
>
Inherited from
Collection.keys
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:129
last
▸ last(): undefined
| Value
Obtains the last value(s) in this collection.
Returns
undefined
| Value
A single value if no amount is provided or an array of values, starting from the start if amount is negative
Inherited from
Collection.last
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:80
▸ last(amount
): Value
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
Value
[]
Inherited from
Collection.last
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:81
lastKey
▸ lastKey(): undefined
| keyof StoreRegistryEntries
Obtains the last key(s) in this collection.
Returns
undefined
| keyof StoreRegistryEntries
A single key if no amount is provided or an array of keys, starting from the start if amount is negative
Inherited from
Collection.lastKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:89
▸ lastKey(amount
): keyof StoreRegistryEntries
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
keyof StoreRegistryEntries
[]
Inherited from
Collection.lastKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:90
load
▸ load(): Promise
<void
>
Loads all the registered stores.
Since
2.1.0
Returns
Promise
<void
>
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:519
map
▸ map<T
>(fn
): T
[]
Maps each item to another value into an array. Identical in behavior to Array.map().
Example
collection.map(user => user.tag);
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => T | Function that produces an element of the new array, taking three arguments |
Returns
T
[]
Inherited from
Collection.map
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:230
▸ map<This
, T
>(fn
, thisArg
): T
[]
Type parameters
Name |
---|
This |
T |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => T |
thisArg | This |
Returns
T
[]
Inherited from
Collection.map
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:231
mapValues
▸ mapValues<T
>(fn
): Collection
<keyof StoreRegistryEntries
, T
>
Maps each item to another value into a collection. Identical in behavior to Array.map().
Example
collection.mapValues(user => user.tag);
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => T | Function that produces an element of the new collection, taking three arguments |
Returns
Collection
<keyof StoreRegistryEntries
, T
>
Inherited from
Collection.mapValues
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:243
▸ mapValues<This
, T
>(fn
, thisArg
): Collection
<keyof StoreRegistryEntries
, T
>
Type parameters
Name |
---|
This |
T |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => T |
thisArg | This |
Returns
Collection
<keyof StoreRegistryEntries
, T
>
Inherited from
Collection.mapValues
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:244
merge
▸ merge<T
, R
>(other
, whenInSelf
, whenInOther
, whenInBoth
): Collection
<keyof StoreRegistryEntries
, R
>
Merges two Collections together into a new Collection.
Example
// Sums up the entries in two collections.
coll.merge(
other,
x => ({ keep: true, value: x }),
y => ({ keep: true, value: y }),
(x, y) => ({ keep: true, value: x + y }),
);
Example
// Intersects two collections in a left-biased manner.
coll.merge(
other,
x => ({ keep: false }),
y => ({ keep: false }),
(x, _) => ({ keep: true, value: x }),
);
Type parameters
Name |
---|
T |
R |
Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyCollection <keyof StoreRegistryEntries , T > | The other Collection to merge with |
whenInSelf | (value : Value , key : keyof StoreRegistryEntries ) => Keep <R > | Function getting the result if the entry only exists in this Collection |
whenInOther | (valueOther : T , key : keyof StoreRegistryEntries ) => Keep <R > | Function getting the result if the entry only exists in the other Collection |
whenInBoth | (value : Value , valueOther : T , key : keyof StoreRegistryEntries ) => Keep <R > | Function getting the result if the entry exists in both Collections |
Returns
Collection
<keyof StoreRegistryEntries
, R
>
Inherited from
Collection.merge
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:407
partition
▸ partition<K2
>(fn
): [Collection
<K2
, Value
>, Collection
<Exclude
<"listeners"
, K2
> | Exclude
<"arguments"
, K2
> | Exclude
<"commands"
, K2
> | Exclude
<"interaction-handlers"
, K2
> | Exclude
<"preconditions"
, K2
>, Value
>]
Partitions the collection into two collections where the first collection contains the items that passed and the second contains the items that failed.
Example
const [big, small] = collection.partition(guild => guild.memberCount > 250);
Type parameters
Name | Type |
---|---|
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 | Function used to test (should return a boolean) |
Returns
[Collection
<K2
, Value
>, Collection
<Exclude
<"listeners"
, K2
> | Exclude
<"arguments"
, K2
> | Exclude
<"commands"
, K2
> | Exclude
<"interaction-handlers"
, K2
> | Exclude
<"preconditions"
, K2
>, Value
>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:200
▸ partition<V2
>(fn
): [Collection
<keyof StoreRegistryEntries
, V2
>, Collection
<keyof StoreRegistryEntries
, Exclude
<ListenerStore
, V2
> | Exclude
<ArgumentStore
, V2
> | Exclude
<CommandStore
, V2
> | Exclude
<InteractionHandlerStore
, V2
> | Exclude
<PreconditionStore
, V2
>>]
Type parameters
Name | Type |
---|---|
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
Returns
[Collection
<keyof StoreRegistryEntries
, V2
>, Collection
<keyof StoreRegistryEntries
, Exclude
<ListenerStore
, V2
> | Exclude
<ArgumentStore
, V2
> | Exclude
<CommandStore
, V2
> | Exclude
<InteractionHandlerStore
, V2
> | Exclude
<PreconditionStore
, V2
>>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:201
▸ partition(fn
): [Collection
<keyof StoreRegistryEntries
, Value
>, Collection
<keyof StoreRegistryEntries
, Value
>]
Parameters
Name | Type |
---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
Returns
[Collection
<keyof StoreRegistryEntries
, Value
>, Collection
<keyof StoreRegistryEntries
, Value
>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:202
▸ partition<This
, K2
>(fn
, thisArg
): [Collection
<K2
, Value
>, Collection
<Exclude
<"listeners"
, K2
> | Exclude
<"arguments"
, K2
> | Exclude
<"commands"
, K2
> | Exclude
<"interaction-handlers"
, K2
> | Exclude
<"preconditions"
, K2
>, Value
>]
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends keyof StoreRegistryEntries |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => key is K2 |
thisArg | This |
Returns
[Collection
<K2
, Value
>, Collection
<Exclude
<"listeners"
, K2
> | Exclude
<"arguments"
, K2
> | Exclude
<"commands"
, K2
> | Exclude
<"interaction-handlers"
, K2
> | Exclude
<"preconditions"
, K2
>, Value
>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:203
▸ partition<This
, V2
>(fn
, thisArg
): [Collection
<keyof StoreRegistryEntries
, V2
>, Collection
<keyof StoreRegistryEntries
, Exclude
<ListenerStore
, V2
> | Exclude
<ArgumentStore
, V2
> | Exclude
<CommandStore
, V2
> | Exclude
<InteractionHandlerStore
, V2
> | Exclude
<PreconditionStore
, V2
>>]
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends Value |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => value is V2 |
thisArg | This |
Returns
[Collection
<keyof StoreRegistryEntries
, V2
>, Collection
<keyof StoreRegistryEntries
, Exclude
<ListenerStore
, V2
> | Exclude
<ArgumentStore
, V2
> | Exclude
<CommandStore
, V2
> | Exclude
<InteractionHandlerStore
, V2
> | Exclude
<PreconditionStore
, V2
>>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:204
▸ partition<This
>(fn
, thisArg
): [Collection
<keyof StoreRegistryEntries
, Value
>, Collection
<keyof StoreRegistryEntries
, Value
>]
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | This |
Returns
[Collection
<keyof StoreRegistryEntries
, Value
>, Collection
<keyof StoreRegistryEntries
, Value
>]
Inherited from
Collection.partition
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:205
random
▸ random(): undefined
| Value
Obtains unique random value(s) from this collection.
Returns
undefined
| Value
A single value if no amount is provided or an array of values
Inherited from
Collection.random
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:113
▸ random(amount
): Value
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
Value
[]
Inherited from
Collection.random
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:114
randomKey
▸ randomKey(): undefined
| keyof StoreRegistryEntries
Obtains unique random key(s) from this collection.
Returns
undefined
| keyof StoreRegistryEntries
A single key if no amount is provided or an array
Inherited from
Collection.randomKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:121
▸ randomKey(amount
): keyof StoreRegistryEntries
[]
Parameters
Name | Type |
---|---|
amount | number |
Returns
keyof StoreRegistryEntries
[]
Inherited from
Collection.randomKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:122
reduce
▸ reduce<T
>(fn
, initialValue?
): T
Applies a function to produce a single value. Identical in behavior to Array.reduce().
Example
collection.reduce((acc, guild) => acc + guild.memberCount, 0);
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
fn | (accumulator : T , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => T | Function used to reduce, taking four arguments; accumulator , currentValue , currentKey , and collection |
initialValue? | T | Starting value for the accumulator |
Returns
T
Inherited from
Collection.reduce
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:287
register
▸ register<T
>(store
): StoreRegistry
Registers a store.
Since
2.1.0
Type parameters
Name | Type |
---|---|
T | extends Piece <PieceOptions , T > |
Parameters
Name | Type | Description |
---|---|---|
store | Store <T > | The store to register. |
Returns
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:550
registerPath
▸ registerPath(rootDirectory?
): void
Registers all user directories from the process working directory, the default value is obtained by assuming
CommonJS (high accuracy) but with fallback for ECMAScript Modules (reads package.json's main
entry, fallbacks
to process.cwd()
).
By default, if you have this folder structure:
/home/me/my-bot
├─ src
│ ├─ commands
│ ├─ events
│ └─ main.js
└─ package.json
And you run node src/main.js
, the directories /home/me/my-bot/src/commands
and /home/me/my-bot/src/events
will
be registered for the commands and events stores respectively, since both directories are located in the same
directory as your main file.
Note: this also registers directories for all other stores, even if they don't have a folder, this allows you to create new pieces and hot-load them later anytime.
Since
2.1.0
Parameters
Name | Type | Description |
---|---|---|
rootDirectory? | Path | The root directory to register pieces at. |
Returns
void
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:544
reverse
▸ reverse(): StoreRegistry
Identical to Array.reverse() but returns a Collection instead of an Array.
Returns
Inherited from
Collection.reverse
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:127
set
▸ set(key
, value
): StoreRegistry
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
Parameters
Name | Type |
---|---|
key | keyof StoreRegistryEntries |
value | Value |
Returns
Inherited from
Collection.set
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:42
some
▸ some(fn
): boolean
Checks if there exists an item that passes a test. Identical in behavior to Array.some().
Example
collection.some(user => user.discriminator === '0000');
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown | Function used to test (should return a boolean) |
Returns
boolean
Inherited from
Collection.some
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:256
▸ some<T
>(fn
, thisArg
): boolean
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (this : T , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | T |
Returns
boolean
Inherited from
Collection.some
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:257
sort
▸ sort(compareFunction?
): StoreRegistry
The sort method sorts the items of a collection in place and returns it. The sort is not necessarily stable in Node 10 or older. The default sort order is according to string Unicode code points.
Example
collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
Parameters
Name | Type | Description |
---|---|---|
compareFunction? | Comparator <keyof StoreRegistryEntries , Value > | Specifies a function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element. |
Returns
Inherited from
Collection.sort
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:360
sorted
▸ sorted(compareFunction?
): Collection
<keyof StoreRegistryEntries
, Value
>
The sorted method sorts the items of a collection and returns it. The sort is not necessarily stable in Node 10 or older. The default sort order is according to string Unicode code points.
Example
collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
Parameters
Name | Type | Description |
---|---|---|
compareFunction? | Comparator <keyof StoreRegistryEntries , Value > | Specifies a function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element. |
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.sorted
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:421
subtract
▸ subtract<T
>(other
): Collection
<keyof StoreRegistryEntries
, Value
>
The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyCollection <keyof StoreRegistryEntries , T > | The other Collection to filter against |
Returns
Collection
<keyof StoreRegistryEntries
, Value
>
Inherited from
Collection.subtract
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:372
sweep
▸ sweep(fn
): number
Removes items that satisfy the provided filter function.
Parameters
Name | Type | Description |
---|---|---|
fn | (value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown | Function used to test (should return a boolean) |
Returns
number
The number of removed entries
Inherited from
Collection.sweep
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:169
▸ sweep<T
>(fn
, thisArg
): number
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (this : T , value : Value , key : keyof StoreRegistryEntries , collection : StoreRegistry ) => unknown |
thisArg | T |
Returns
number
Inherited from
Collection.sweep
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:170
tap
▸ tap(fn
): StoreRegistry
Runs a function on the collection and returns the collection.
Example
collection
.tap(coll => console.log(coll.size))
.filter(user => user.bot)
.tap(coll => console.log(coll.size))
Parameters
Name | Type | Description |
---|---|---|
fn | (collection : StoreRegistry ) => void | Function to execute |
Returns
Inherited from
Collection.tap
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:318
▸ tap<T
>(fn
, thisArg
): StoreRegistry
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (this : T , collection : StoreRegistry ) => void |
thisArg | T |
Returns
Inherited from
Collection.tap
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:319
toJSON
▸ toJSON(): Value
[]
Returns
Value
[]
Inherited from
Collection.toJSON
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:422
values
▸ values(): IterableIterator
<Value
>
Returns an iterable of values in the map
Returns
IterableIterator
<Value
>
Inherited from
Collection.values
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:134
combineEntries
▸ Static
combineEntries<K
, V
>(entries
, combine
): Collection
<K
, V
>
Creates a Collection from a list of entries.
Example
Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
// returns Collection { "a" => 3, "b" => 2 }
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type | Description |
---|---|---|
entries | Iterable <[K , V ]> | The list of entries |
combine | (firstValue : V , secondValue : V , key : K ) => V | Function to combine an existing entry with a new one |
Returns
Collection
<K
, V
>
Inherited from
Collection.combineEntries
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:435