Skip to main content

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​

NameType
entries?null | readonly readonly [keyof StoreRegistryEntries, Value][]

Inherited from​

Collection<Key, Value>.constructor

Defined in​

node_modules/typescript/lib/lib.es2015.collection.d.ts:33

β€’ new StoreRegistry(iterable)

Parameters​

NameType
iterableIterable<readonly [keyof StoreRegistryEntries, Value]>

Inherited from​

Collection<Key, Value>.constructor

Defined in​

node_modules/typescript/lib/lib.es2015.iterable.d.ts:160

Properties​

[toStringTag]​

β€’ Readonly [toStringTag]: string

Inherited from​

Collection.__@toStringTag@329

Defined in​

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:135


constructor​

β€’ constructor: CollectionConstructor

Inherited from​

Collection.constructor

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:17


size​

β€’ Readonly size: number

Inherited from​

Collection.size

Defined in​

node_modules/typescript/lib/lib.es2015.collection.d.ts:28


[species]​

β–ͺ Static Readonly [species]: MapConstructor

Inherited from​

Collection.__@species@49

Defined in​

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:317


default​

β–ͺ Static Readonly default: typeof Collection

Inherited from​

Collection.default

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:24

Methods​

[iterator]​

β–Έ [iterator](): IterableIterator<[keyof StoreRegistryEntries, Value]>

Returns an iterable of entries in the map.

Returns​

IterableIterator<[keyof StoreRegistryEntries, Value]>

Inherited from​

Collection.__@iterator@58

Defined in​

node_modules/typescript/lib/lib.es2015.iterable.d.ts:121


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​

NameTypeDescription
index?numberThe index of the element to obtain

Returns​

undefined | Value

Inherited from​

Collection.at

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:87


clear​

β–Έ clear(): void

Returns​

void

Inherited from​

Collection.clear

Defined in​

node_modules/typescript/lib/lib.es2015.collection.d.ts:22


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:301


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​

NameTypeDescription
...collectionsCollection<keyof StoreRegistryEntries, Value>[]Collections to merge

Returns​

Collection<keyof StoreRegistryEntries, Value>

Inherited from​

Collection.concat

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:310


delete​

β–Έ delete(key): boolean

Parameters​

NameType
keykeyof StoreRegistryEntries

Returns​

boolean

Inherited from​

Collection.delete

Defined in​

node_modules/typescript/lib/lib.es2015.collection.d.ts:23


deregister​

β–Έ deregister<T>(store): StoreRegistry

Deregisters a store.

since 2.1.0

Type parameters​

NameType
Textends Piece<PieceOptions, T>

Parameters​

NameTypeDescription
storeStore<T>The store to deregister.

Returns​

StoreRegistry

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:553


difference​

β–Έ difference(other): Collection<keyof StoreRegistryEntries, Value>

The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.

Parameters​

NameTypeDescription
otherCollection<keyof StoreRegistryEntries, Value>The other Collection to filter against

Returns​

Collection<keyof StoreRegistryEntries, Value>

Inherited from​

Collection.difference

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:344


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​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => voidFunction to execute for each element

Returns​

StoreRegistry

Inherited from​

Collection.each

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:279

β–Έ each<T>(fn, thisArg): StoreRegistry

Type parameters​

Name
T

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => void
thisArgT

Returns​

StoreRegistry

Inherited from​

Collection.each

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:280


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:126


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​

NameTypeDescription
collectionCollection<keyof StoreRegistryEntries, Value>Collection to compare with

Returns​

boolean

Whether the collections have identical contents

Inherited from​

Collection.equals

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:320


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​

NameType
K2extends keyof StoreRegistryEntries

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2Function used to test (should return a boolean)

Returns​

this is Collection<K2, Value>

Inherited from​

Collection.every

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:247

β–Έ every<V2>(fn): this is Collection<keyof StoreRegistryEntries, V2>

Type parameters​

NameType
V2extends Value

Parameters​

NameType
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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:248

β–Έ every(fn): boolean

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean

Returns​

boolean

Inherited from​

Collection.every

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:249

β–Έ every<This, K2>(fn, thisArg): this is Collection<K2, Value>

Type parameters​

NameType
ThisThis
K2extends keyof StoreRegistryEntries

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2
thisArgThis

Returns​

this is Collection<K2, Value>

Inherited from​

Collection.every

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:250

β–Έ every<This, V2>(fn, thisArg): this is Collection<keyof StoreRegistryEntries, V2>

Type parameters​

NameType
ThisThis
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2
thisArgThis

Returns​

this is Collection<keyof StoreRegistryEntries, V2>

Inherited from​

Collection.every

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:251

β–Έ every<This>(fn, thisArg): boolean

Type parameters​

Name
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgThis

Returns​

boolean

Inherited from​

Collection.every

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:252


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​

NameType
K2extends keyof StoreRegistryEntries

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2The function to test with (should return boolean)

Returns​

Collection<K2, Value>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:167

β–Έ filter<V2>(fn): Collection<keyof StoreRegistryEntries, V2>

Type parameters​

NameType
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2

Returns​

Collection<keyof StoreRegistryEntries, V2>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:168

β–Έ filter(fn): Collection<keyof StoreRegistryEntries, Value>

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean

Returns​

Collection<keyof StoreRegistryEntries, Value>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:169

β–Έ filter<This, K2>(fn, thisArg): Collection<K2, Value>

Type parameters​

NameType
ThisThis
K2extends keyof StoreRegistryEntries

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2
thisArgThis

Returns​

Collection<K2, Value>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:170

β–Έ filter<This, V2>(fn, thisArg): Collection<keyof StoreRegistryEntries, V2>

Type parameters​

NameType
ThisThis
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2
thisArgThis

Returns​

Collection<keyof StoreRegistryEntries, V2>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:171

β–Έ filter<This>(fn, thisArg): Collection<keyof StoreRegistryEntries, Value>

Type parameters​

Name
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgThis

Returns​

Collection<keyof StoreRegistryEntries, Value>

Inherited from​

Collection.filter

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:172


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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.

example collection.find(user => user.username === 'Bob');

Type parameters​

NameType
V2extends Value

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2The function to test with (should return boolean)

Returns​

undefined | V2

Inherited from​

Collection.find

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:127

β–Έ find(fn): undefined | Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean

Returns​

undefined | Value

Inherited from​

Collection.find

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:128

β–Έ find<This, V2>(fn, thisArg): undefined | V2

Type parameters​

NameType
ThisThis
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2
thisArgThis

Returns​

undefined | V2

Inherited from​

Collection.find

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:129

β–Έ find<This>(fn, thisArg): undefined | Value

Type parameters​

Name
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgThis

Returns​

undefined | Value

Inherited from​

Collection.find

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:130


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​

NameType
K2extends keyof StoreRegistryEntries

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2The function to test with (should return boolean)

Returns​

undefined | K2

Inherited from​

Collection.findKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:142

β–Έ findKey(fn): undefined | keyof StoreRegistryEntries

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean

Returns​

undefined | keyof StoreRegistryEntries

Inherited from​

Collection.findKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:143

β–Έ findKey<This, K2>(fn, thisArg): undefined | K2

Type parameters​

NameType
ThisThis
K2extends keyof StoreRegistryEntries

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2
thisArgThis

Returns​

undefined | K2

Inherited from​

Collection.findKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:144

β–Έ findKey<This>(fn, thisArg): undefined | keyof StoreRegistryEntries

Type parameters​

Name
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgThis

Returns​

undefined | keyof StoreRegistryEntries

Inherited from​

Collection.findKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:145


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:48

β–Έ first(amount): Value[]

Parameters​

NameType
amountnumber

Returns​

Value[]

Inherited from​

Collection.first

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:49


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:58

β–Έ firstKey(amount): keyof StoreRegistryEntries[]

Parameters​

NameType
amountnumber

Returns​

keyof StoreRegistryEntries[]

Inherited from​

Collection.firstKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:59


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​

NameTypeDescription
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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:199

β–Έ flatMap<T, This>(fn, thisArg): Collection<keyof StoreRegistryEntries, T>

Type parameters​

Name
T
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => Collection<keyof StoreRegistryEntries, T>
thisArgThis

Returns​

Collection<keyof StoreRegistryEntries, T>

Inherited from​

Collection.flatMap

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:200


forEach​

β–Έ forEach(callbackfn, thisArg?): void

Parameters​

NameType
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:24


get​

β–Έ get<K>(key): StoreRegistryEntries[K]

Type parameters​

NameType
Kextends keyof StoreRegistryEntries

Parameters​

NameType
keyK

Returns​

StoreRegistryEntries[K]

Inherited from​

Collection.get

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:556

β–Έ get(key): undefined

Parameters​

NameType
keystring

Returns​

undefined

Inherited from​

Collection.get

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:557


has​

β–Έ has(key): true

Parameters​

NameType
keykeyof StoreRegistryEntries

Returns​

true

Inherited from​

Collection.has

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:558

β–Έ has(key): false

Parameters​

NameType
keystring

Returns​

false

Inherited from​

Collection.has

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:559


hasAll​

β–Έ hasAll(...keys): boolean

Checks if all of the elements exist in the collection.

Parameters​

NameTypeDescription
...keyskeyof 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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:32


hasAny​

β–Έ hasAny(...keys): boolean

Checks if any of the elements exist in the collection.

Parameters​

NameTypeDescription
...keyskeyof 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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:40


intersect​

β–Έ intersect(other): Collection<keyof StoreRegistryEntries, Value>

The intersect method returns a new structure containing items where the keys are present in both original structures.

Parameters​

NameTypeDescription
otherCollection<keyof StoreRegistryEntries, Value>The other Collection to filter against

Returns​

Collection<keyof StoreRegistryEntries, Value>

Inherited from​

Collection.intersect

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:338


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​

NameTypeDescription
index?numberThe index of the key to obtain

Returns​

undefined | keyof StoreRegistryEntries

Inherited from​

Collection.keyAt

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:95


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:131


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:68

β–Έ last(amount): Value[]

Parameters​

NameType
amountnumber

Returns​

Value[]

Inherited from​

Collection.last

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:69


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:78

β–Έ lastKey(amount): keyof StoreRegistryEntries[]

Parameters​

NameType
amountnumber

Returns​

keyof StoreRegistryEntries[]

Inherited from​

Collection.lastKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:79


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:516


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​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => TFunction that produces an element of the new array, taking three arguments

Returns​

T[]

Inherited from​

Collection.map

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:211

β–Έ map<This, T>(fn, thisArg): T[]

Type parameters​

Name
This
T

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => T
thisArgThis

Returns​

T[]

Inherited from​

Collection.map

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:212


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​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => TFunction that produces an element of the new collection, taking three arguments

Returns​

Collection<keyof StoreRegistryEntries, T>

Inherited from​

Collection.mapValues

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:223

β–Έ mapValues<This, T>(fn, thisArg): Collection<keyof StoreRegistryEntries, T>

Type parameters​

Name
This
T

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => T
thisArgThis

Returns​

Collection<keyof StoreRegistryEntries, T>

Inherited from​

Collection.mapValues

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:224


partition​

β–Έ partition<K2>(fn): [Collection<K2, Value>, Collection<Exclude<"arguments", K2> | Exclude<"commands", K2> | Exclude<"interaction-handlers", K2> | Exclude<"listeners", 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​

NameType
K2extends keyof StoreRegistryEntries

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2Function used to test (should return a boolean)

Returns​

[Collection<K2, Value>, Collection<Exclude<"arguments", K2> | Exclude<"commands", K2> | Exclude<"interaction-handlers", K2> | Exclude<"listeners", K2> | Exclude<"preconditions", K2>, Value>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:183

β–Έ partition<V2>(fn): [Collection<keyof StoreRegistryEntries, V2>, Collection<keyof StoreRegistryEntries, Exclude<ArgumentStore, V2> | Exclude<CommandStore, V2> | Exclude<InteractionHandlerStore, V2> | Exclude<ListenerStore, V2> | Exclude<PreconditionStore, V2>>]

Type parameters​

NameType
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2

Returns​

[Collection<keyof StoreRegistryEntries, V2>, Collection<keyof StoreRegistryEntries, Exclude<ArgumentStore, V2> | Exclude<CommandStore, V2> | Exclude<InteractionHandlerStore, V2> | Exclude<ListenerStore, V2> | Exclude<PreconditionStore, V2>>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:184

β–Έ partition(fn): [Collection<keyof StoreRegistryEntries, Value>, Collection<keyof StoreRegistryEntries, Value>]

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean

Returns​

[Collection<keyof StoreRegistryEntries, Value>, Collection<keyof StoreRegistryEntries, Value>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:185

β–Έ partition<This, K2>(fn, thisArg): [Collection<K2, Value>, Collection<Exclude<"arguments", K2> | Exclude<"commands", K2> | Exclude<"interaction-handlers", K2> | Exclude<"listeners", K2> | Exclude<"preconditions", K2>, Value>]

Type parameters​

NameType
ThisThis
K2extends keyof StoreRegistryEntries

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => key is K2
thisArgThis

Returns​

[Collection<K2, Value>, Collection<Exclude<"arguments", K2> | Exclude<"commands", K2> | Exclude<"interaction-handlers", K2> | Exclude<"listeners", K2> | Exclude<"preconditions", K2>, Value>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:186

β–Έ partition<This, V2>(fn, thisArg): [Collection<keyof StoreRegistryEntries, V2>, Collection<keyof StoreRegistryEntries, Exclude<ArgumentStore, V2> | Exclude<CommandStore, V2> | Exclude<InteractionHandlerStore, V2> | Exclude<ListenerStore, V2> | Exclude<PreconditionStore, V2>>]

Type parameters​

NameType
ThisThis
V2extends Value

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => value is V2
thisArgThis

Returns​

[Collection<keyof StoreRegistryEntries, V2>, Collection<keyof StoreRegistryEntries, Exclude<ArgumentStore, V2> | Exclude<CommandStore, V2> | Exclude<InteractionHandlerStore, V2> | Exclude<ListenerStore, V2> | Exclude<PreconditionStore, V2>>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:187

β–Έ partition<This>(fn, thisArg): [Collection<keyof StoreRegistryEntries, Value>, Collection<keyof StoreRegistryEntries, Value>]

Type parameters​

Name
This

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgThis

Returns​

[Collection<keyof StoreRegistryEntries, Value>, Collection<keyof StoreRegistryEntries, Value>]

Inherited from​

Collection.partition

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:188


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:103

β–Έ random(amount): Value[]

Parameters​

NameType
amountnumber

Returns​

Value[]

Inherited from​

Collection.random

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:104


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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:112

β–Έ randomKey(amount): keyof StoreRegistryEntries[]

Parameters​

NameType
amountnumber

Returns​

keyof StoreRegistryEntries[]

Inherited from​

Collection.randomKey

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:113


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​

NameTypeDescription
fn(accumulator: T, value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => TFunction used to reduce, taking four arguments; accumulator, currentValue, currentKey, and collection
initialValue?TStarting value for the accumulator

Returns​

T

Inherited from​

Collection.reduce

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:264


register​

β–Έ register<T>(store): StoreRegistry

Registers a store.

since 2.1.0

Type parameters​

NameType
Textends Piece<PieceOptions, T>

Parameters​

NameTypeDescription
storeStore<T>The store to register.

Returns​

StoreRegistry

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:547


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​

NameTypeDescription
rootDirectory?stringThe root directory to register pieces at.

Returns​

void

Defined in​

node_modules/@sapphire/pieces/dist/index.d.ts:541


set​

β–Έ set(key, value): StoreRegistry

Parameters​

NameType
keykeyof StoreRegistryEntries
valueValue

Returns​

StoreRegistry

Inherited from​

Collection.set

Defined in​

node_modules/typescript/lib/lib.es2015.collection.d.ts:27


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​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => booleanFunction used to test (should return a boolean)

Returns​

boolean

Inherited from​

Collection.some

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:235

β–Έ some<T>(fn, thisArg): boolean

Type parameters​

Name
T

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgT

Returns​

boolean

Inherited from​

Collection.some

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:236


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​

NameTypeDescription
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​

StoreRegistry

Inherited from​

Collection.sort

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:332


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​

NameTypeDescription
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/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:357


sweep​

β–Έ sweep(fn): number

Removes items that satisfy the provided filter function.

Parameters​

NameTypeDescription
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => booleanFunction used to test (should return a boolean)

Returns​

number

The number of removed entries

Inherited from​

Collection.sweep

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:154

β–Έ sweep<T>(fn, thisArg): number

Type parameters​

Name
T

Parameters​

NameType
fn(value: Value, key: keyof StoreRegistryEntries, collection: StoreRegistry) => boolean
thisArgT

Returns​

number

Inherited from​

Collection.sweep

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:155


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​

NameTypeDescription
fn(collection: StoreRegistry) => voidFunction to execute

Returns​

StoreRegistry

Inherited from​

Collection.tap

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:293

β–Έ tap<T>(fn, thisArg): StoreRegistry

Type parameters​

Name
T

Parameters​

NameType
fn(collection: StoreRegistry) => void
thisArgT

Returns​

StoreRegistry

Inherited from​

Collection.tap

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:294


toJSON​

β–Έ toJSON(): Value[]

Returns​

Value[]

Inherited from​

Collection.toJSON

Defined in​

node_modules/@sapphire/pieces/node_modules/@discordjs/collection/dist/index.d.ts:358


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:136