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
<StoreRegistryKey
,StoreRegistryValue
>↳
StoreRegistry
Constructors
constructor
• new StoreRegistry(entries?
): StoreRegistry
Parameters
Name | Type |
---|---|
entries? | null | readonly readonly [never , never ][] |
Returns
Inherited from
Collection<StoreRegistryKey, StoreRegistryValue>.constructor
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:50
• new StoreRegistry(iterable?
): StoreRegistry
Parameters
Name | Type |
---|---|
iterable? | null | Iterable <readonly [never , never ]> |
Returns
Inherited from
Collection<StoreRegistryKey, StoreRegistryValue>.constructor
Defined in
node_modules/typescript/lib/lib.es2015.collection.d.ts:49
node_modules/typescript/lib/lib.es2015.collection.d.ts:50
Properties
#pendingManuallyRegisteredPieces
• Private
Readonly
#pendingManuallyRegisteredPieces: Collection
<never
, StoreManuallyRegisteredPiece
<never
>[]>
The queue of pieces to load.
Defined in
projects/pieces/src/lib/structures/StoreRegistry.ts:35
[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:45
[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
<[never
, never
]>
Returns an iterable of entries in the map.
Returns
IterableIterator
<[never
, never
]>
Inherited from
Collection.[iterator]
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:119
at
▸ at(index
): undefined
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
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:20
clone
▸ clone(): Collection
<never
, never
>
Creates an identical shallow copy of this collection.
Returns
Collection
<never
, never
>
Example
const newColl = someColl.clone();
Inherited from
Collection.clone
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:328
concat
▸ concat(...collections
): Collection
<never
, never
>
Combines this collection with others into a new collection. None of the source collections are modified.
Parameters
Name | Type | Description |
---|---|---|
...collections | ReadonlyCollection <never , never >[] | Collections to merge |
Returns
Collection
<never
, never
>
Example
const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
Inherited from
Collection.concat
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:338
delete
▸ delete(key
): boolean
Parameters
Name | Type |
---|---|
key | never |
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:24
deregister
▸ deregister<T
>(store
): this
Deregisters a store.
Type parameters
Name | Type |
---|---|
T | extends Piece <PieceOptions , never > |
Parameters
Name | Type | Description |
---|---|---|
store | Store <T , never > | The store to deregister. |
Returns
this
Since
2.1.0
Defined in
projects/pieces/src/lib/structures/StoreRegistry.ts:126
difference
▸ difference<T
>(other
): Collection
<never
, 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 <never , T > | The other Collection to filter against |
Returns
Collection
<never
, T
>
Inherited from
Collection.difference
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:378
each
▸ each(fn
): this
Identical to Map.forEach(), but returns the collection instead of undefined.
Parameters
Name | Type | Description |
---|---|---|
fn | (value : never , key : never , collection : this ) => void | Function to execute for each element |
Returns
this
Example
collection
.each(user => console.log(user.username))
.filter(user => user.bot)
.each(user => console.log(user.username));
Inherited from
Collection.each
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:303
▸ each<T
>(fn
, thisArg
): this
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
fn | (this : T , value : never , key : never , collection : this ) => void |
thisArg | T |
Returns
this
Inherited from
Collection.each
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:304
ensure
▸ ensure(key
, defaultValueGenerator
): never
Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
Parameters
Name | Type | Description |
---|---|---|
key | never | The key to get if it exists, or set otherwise |
defaultValueGenerator | (key : never , collection : this ) => never | A function that generates the default value |
Returns
never
Example
collection.ensure(guildId, () => defaultGuildConfig);
Inherited from
Collection.ensure
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:41
entries
▸ entries(): IterableIterator
<[never
, never
]>
Returns an iterable of key, value pairs for every entry in the map.
Returns
IterableIterator
<[never
, never
]>
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 <never , never > | 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, never>
Checks if all items passes a test. Identical in behavior to Array.every().
Type parameters
Name | Type |
---|---|
K2 | extends never |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : never , key : never , collection : this ) => key is K2 | Function used to test (should return a boolean) |
Returns
this is Collection<K2, never>
Example
collection.every(user => !user.bot);
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:269
▸ every<V2
>(fn
): this is Collection<never, V2>
Type parameters
Name | Type |
---|---|
V2 | extends never |
Parameters
Name | Type |
---|---|
fn | (value : never , key : never , collection : this ) => value is V2 |
Returns
this is Collection<never, V2>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:270
▸ every(fn
): boolean
Parameters
Name | Type |
---|---|
fn | (value : never , key : never , collection : this ) => 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, never>
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends never |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => key is K2 |
thisArg | This |
Returns
this is Collection<K2, never>
Inherited from
Collection.every
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:272
▸ every<This
, V2
>(fn
, thisArg
): this is Collection<never, V2>
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends never |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => value is V2 |
thisArg | This |
Returns
this is Collection<never, 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 : never , key : never , collection : this ) => 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
, never
>
Identical to Array.filter(), but returns a Collection instead of an Array.
Type parameters
Name | Type |
---|---|
K2 | extends never |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : never , key : never , collection : this ) => key is K2 | The function to test with (should return boolean) |
Returns
Collection
<K2
, never
>
Example
collection.filter(user => user.username === 'Bob');
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:183
▸ filter<V2
>(fn
): Collection
<never
, V2
>
Type parameters
Name | Type |
---|---|
V2 | extends never |
Parameters
Name | Type |
---|---|
fn | (value : never , key : never , collection : this ) => value is V2 |
Returns
Collection
<never
, V2
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:184
▸ filter(fn
): Collection
<never
, never
>
Parameters
Name | Type |
---|---|
fn | (value : never , key : never , collection : this ) => unknown |
Returns
Collection
<never
, never
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:185
▸ filter<This
, K2
>(fn
, thisArg
): Collection
<K2
, never
>
Type parameters
Name | Type |
---|---|
This | This |
K2 | extends never |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => key is K2 |
thisArg | This |
Returns
Collection
<K2
, never
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:186
▸ filter<This
, V2
>(fn
, thisArg
): Collection
<never
, V2
>
Type parameters
Name | Type |
---|---|
This | This |
V2 | extends never |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => value is V2 |
thisArg | This |
Returns
Collection
<never
, V2
>
Inherited from
Collection.filter
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:187
▸ filter<This
>(fn
, thisArg
): Collection
<never
, never
>
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => unknown |
thisArg | This |
Returns
Collection
<never
, never
>
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.
Type parameters
Name | Type |
---|---|
V2 | extends never |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : never , key : never , collection : this ) => value is V2 | The function to test with (should return boolean) |
Returns
undefined
| V2
Example
collection.find(user => user.username === 'Bob');
Inherited from
Collection.find
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:142
▸ find(fn
): undefined
Parameters
Name | Type |
---|---|
fn | (value : never , key : never , collection : this ) => unknown |
Returns
undefined
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 never |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => 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
Type parameters
Name |
---|
This |
Parameters
Name | Type |
---|---|
fn | (this : This , value : never , key : never , collection : this ) => unknown |
thisArg | This |
Returns
undefined
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.
Type parameters
Name | Type |
---|---|
K2 | extends never |
Parameters
Name | Type | Description |
---|---|---|
fn | (value : never , key : never , collection : this ) => key is K2 | The function to test with (should return boolean) |
Returns
undefined
| K2
Example
collection.findKey(user => user.username === 'Bob');
Inherited from
Collection.findKey
Defined in
node_modules/@discordjs/collection/dist/index.d.ts:158
▸ findKey(fn
): undefined