Skip to main content

Class: Store<T>

The store class which contains Pieces.

Type parameters​

NameType
Textends Piece

Hierarchy​

  • Collection<string, T>

    ↳ Store

    ↳↳ AliasStore

Constructors​

constructor​

β€’ new Store<T>(constructor, options)

Type parameters​

NameType
Textends Piece<PieceOptions, T>

Parameters​

NameTypeDescription
constructorConstructor<T>The piece constructor this store loads.
optionsStoreOptions<T>The options for the store.

Overrides​

Collection<string, T\>.constructor

Defined in​

projects/pieces/src/lib/structures/Store.ts:62

Properties​

Constructor​

β€’ Readonly Constructor: Constructor<T>

Defined in​

projects/pieces/src/lib/structures/Store.ts:53


[toStringTag]​

β€’ Readonly [toStringTag]: string

Inherited from​

Collection.__@toStringTag@11507

Defined in​

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


constructor​

β€’ constructor: CollectionConstructor

Inherited from​

Collection.constructor

Defined in​

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


name​

β€’ Readonly name: string

Defined in​

projects/pieces/src/lib/structures/Store.ts:54


paths​

β€’ Readonly paths: Set<string>

Defined in​

projects/pieces/src/lib/structures/Store.ts:55


size​

β€’ Readonly size: number

Inherited from​

Collection.size

Defined in​

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


strategy​

β€’ Readonly strategy: ILoaderStrategy<T>

Defined in​

projects/pieces/src/lib/structures/Store.ts:56


[species]​

β–ͺ Static Readonly [species]: MapConstructor

Inherited from​

Collection.__@species@12076

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/@discordjs/collection/dist/index.d.ts:24


defaultStrategy​

β–ͺ Static defaultStrategy: ILoaderStrategy<any>

The default strategy, defaults to LoaderStrategy, which is constructed on demand when a store is constructed, when none was set beforehand.

Defined in​

projects/pieces/src/lib/structures/Store.ts:301


logger​

β–ͺ Static logger: null | StoreLogger = null

The default logger, defaults to null.

Defined in​

projects/pieces/src/lib/structures/Store.ts:306

Accessors​

container​

β€’ get container(): Container

A reference to the Container object for ease of use.

see container

Returns​

Container

Defined in​

projects/pieces/src/lib/structures/Store.ts:74

Methods​

[iterator]​

β–Έ [iterator](): IterableIterator<[string, T]>

Returns an iterable of entries in the map.

Returns​

IterableIterator<[string, T]>

Inherited from​

Collection.__@iterator@11564

Defined in​

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


at​

β–Έ at(index): undefined | T

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
indexnumberThe index of the element to obtain

Returns​

undefined | T

Inherited from​

Collection.at

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:97


clear​

β–Έ clear(): void

Returns​

void

Inherited from​

Collection.clear

Defined in​

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


clone​

β–Έ clone(): Collection<string, T>

Creates an identical shallow copy of this collection.

example const newColl = someColl.clone();

Returns​

Collection<string, T>

Inherited from​

Collection.clone

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:316


concat​

β–Έ concat(...collections): Collection<string, T>

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<string, T>[]Collections to merge

Returns​

Collection<string, T>

Inherited from​

Collection.concat

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:325


construct​

β–Έ construct(Ctor, data): T

Constructs a Piece instance.

Parameters​

NameTypeDescription
CtorILoaderResultEntry<T>The Piece's constructor used to build the instance.
dataHydratedModuleDataThe module's information

Returns​

T

An instance of the constructed piece.

Defined in​

projects/pieces/src/lib/structures/Store.ts:238


delete​

β–Έ delete(key): boolean

Parameters​

NameType
keystring

Returns​

boolean

Inherited from​

Collection.delete

Defined in​

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


difference​

β–Έ difference(other): Collection<string, 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.

Parameters​

NameTypeDescription
otherCollection<string, T>The other Collection to filter against

Returns​

Collection<string, T>

Inherited from​

Collection.difference

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:359


each​

β–Έ each(fn): Store<T>

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: T, key: string, collection: Store<T>) => voidFunction to execute for each element

Returns​

Store<T>

Inherited from​

Collection.each

Defined in​

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

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

Type parameters​

Name
T

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => void
thisArgT

Returns​

Store<T>

Inherited from​

Collection.each

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:295


ensure​

β–Έ ensure(key, defaultValueGenerator): T

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​

NameTypeDescription
keystringThe key to get if it exists, or set otherwise
defaultValueGenerator(key: string, collection: Store<T>) => TA function that generates the default value

Returns​

T

Inherited from​

Collection.ensure

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:34


entries​

β–Έ entries(): IterableIterator<[string, T]>

Returns an iterable of key, value pairs for every entry in the map.

Returns​

IterableIterator<[string, T]>

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<string, T>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:335


every​

β–Έ every<K2>(fn): this is Collection<K2, T>

Checks if all items passes a test. Identical in behavior to Array.every().

example collection.every(user => !user.bot);

Type parameters​

NameType
K2extends string

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => key is K2Function used to test (should return a boolean)

Returns​

this is Collection<K2, T>

Inherited from​

Collection.every

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:262

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

Type parameters​

NameType
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2

Returns​

this is Collection<string, V2>

Inherited from​

Collection.every

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:263

β–Έ every(fn): boolean

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean

Returns​

boolean

Inherited from​

Collection.every

Defined in​

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

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

Type parameters​

NameType
ThisThis
K2extends string

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => key is K2
thisArgThis

Returns​

this is Collection<K2, T>

Inherited from​

Collection.every

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:265

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

Type parameters​

NameType
ThisThis
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2
thisArgThis

Returns​

this is Collection<string, V2>

Inherited from​

Collection.every

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:266

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

Type parameters​

Name
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgThis

Returns​

boolean

Inherited from​

Collection.every

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:267


filter​

β–Έ filter<K2>(fn): Collection<K2, T>

Identical to Array.filter(), but returns a Collection instead of an Array.

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

Type parameters​

NameType
K2extends string

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => key is K2The function to test with (should return boolean)

Returns​

Collection<K2, T>

Inherited from​

Collection.filter

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:182

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

Type parameters​

NameType
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2

Returns​

Collection<string, V2>

Inherited from​

Collection.filter

Defined in​

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

β–Έ filter(fn): Collection<string, T>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean

Returns​

Collection<string, T>

Inherited from​

Collection.filter

Defined in​

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

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

Type parameters​

NameType
ThisThis
K2extends string

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => key is K2
thisArgThis

Returns​

Collection<K2, T>

Inherited from​

Collection.filter

Defined in​

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

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

Type parameters​

NameType
ThisThis
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2
thisArgThis

Returns​

Collection<string, V2>

Inherited from​

Collection.filter

Defined in​

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

β–Έ filter<This>(fn, thisArg): Collection<string, T>

Type parameters​

Name
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgThis

Returns​

Collection<string, T>

Inherited from​

Collection.filter

Defined in​

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


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 Piece<PieceOptions, V2>

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => value is V2The 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 | T

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean

Returns​

undefined | T

Inherited from​

Collection.find

Defined in​

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

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

Type parameters​

NameType
ThisThis
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2
thisArgThis

Returns​

undefined | V2

Inherited from​

Collection.find

Defined in​

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

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

Type parameters​

Name
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgThis

Returns​

undefined | T

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​

NameType
K2extends string

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => key is K2The function to test with (should return boolean)

Returns​

undefined | K2

Inherited from​

Collection.findKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:157

β–Έ findKey(fn): undefined | string

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean

Returns​

undefined | string

Inherited from​

Collection.findKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:158

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

Type parameters​

NameType
ThisThis
K2extends string

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => key is K2
thisArgThis

Returns​

undefined | K2

Inherited from​

Collection.findKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:159

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

Type parameters​

Name
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgThis

Returns​

undefined | string

Inherited from​

Collection.findKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:160


first​

β–Έ first(): undefined | T

Obtains the first value(s) in this collection.

Returns​

undefined | T

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

β–Έ first(amount): T[]

Parameters​

NameType
amountnumber

Returns​

T[]

Inherited from​

Collection.first

Defined in​

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


firstKey​

β–Έ firstKey(): undefined | string

Obtains the first key(s) in this collection.

Returns​

undefined | string

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

β–Έ firstKey(amount): string[]

Parameters​

NameType
amountnumber

Returns​

string[]

Inherited from​

Collection.firstKey

Defined in​

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


flatMap​

β–Έ flatMap<T>(fn): Collection<string, 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: T, key: string, collection: Store<T>) => Collection<string, T>Function that produces a new Collection

Returns​

Collection<string, T>

Inherited from​

Collection.flatMap

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:214

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

Type parameters​

Name
T
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => Collection<string, T>
thisArgThis

Returns​

Collection<string, T>

Inherited from​

Collection.flatMap

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:215


forEach​

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

Parameters​

NameType
callbackfn(value: T, key: string, map: Map<string, T>) => void
thisArg?any

Returns​

void

Inherited from​

Collection.forEach

Defined in​

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


get​

β–Έ get(key): undefined | T

Parameters​

NameType
keystring

Returns​

undefined | T

Inherited from​

Collection.get

Defined in​

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


has​

β–Έ has(key): boolean

Parameters​

NameType
keystring

Returns​

boolean

Inherited from​

Collection.has

Defined in​

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


hasAll​

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

Checks if all of the elements exist in the collection.

Parameters​

NameTypeDescription
...keysstring[]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:42


hasAny​

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

Checks if any of the elements exist in the collection.

Parameters​

NameTypeDescription
...keysstring[]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:50


hydrateModuleData​

β–Έ Private hydrateModuleData(root, data): HydratedModuleData

Adds the final module data properties.

Parameters​

NameTypeDescription
rootstringThe root directory to add.
dataModuleDataThe module data returned from ILoaderStrategy.filter.

Returns​

HydratedModuleData

The finished module data.

Defined in​

projects/pieces/src/lib/structures/Store.ts:248


insert​

β–Έ insert(piece): Promise<T>

Inserts a piece into the store.

Parameters​

NameTypeDescription
pieceTThe piece to be inserted into the store.

Returns​

Promise<T>

The inserted piece.

Defined in​

projects/pieces/src/lib/structures/Store.ts:201


intersect​

β–Έ intersect(other): Collection<string, T>

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

Parameters​

NameTypeDescription
otherCollection<string, T>The other Collection to filter against

Returns​

Collection<string, T>

Inherited from​

Collection.intersect

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:353


keyAt​

β–Έ keyAt(index): undefined | string

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
indexnumberThe index of the key to obtain

Returns​

undefined | string

Inherited from​

Collection.keyAt

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:105


keys​

β–Έ keys(): IterableIterator<string>

Returns an iterable of keys in the map

Returns​

IterableIterator<string>

Inherited from​

Collection.keys

Defined in​

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


last​

β–Έ last(): undefined | T

Obtains the last value(s) in this collection.

Returns​

undefined | T

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

β–Έ last(amount): T[]

Parameters​

NameType
amountnumber

Returns​

T[]

Inherited from​

Collection.last

Defined in​

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


lastKey​

β–Έ lastKey(): undefined | string

Obtains the last key(s) in this collection.

Returns​

undefined | string

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

β–Έ lastKey(amount): string[]

Parameters​

NameType
amountnumber

Returns​

string[]

Inherited from​

Collection.lastKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:89


load​

β–Έ load(root, path): Promise<T[]>

Loads one or more pieces from a path.

Parameters​

NameTypeDescription
rootstringThe root directory the file is from.
pathstringThe path of the file to load, relative to the root.

Returns​

Promise<T[]>

All the loaded pieces.

Defined in​

projects/pieces/src/lib/structures/Store.ts:100


loadAll​

β–Έ loadAll(): Promise<void>

Loads all pieces from all directories specified by paths.

Returns​

Promise<void>

Defined in​

projects/pieces/src/lib/structures/Store.ts:155


loadPath​

β–Έ Private loadPath(root): AsyncIterableIterator<T>

Loads a directory into the store.

Parameters​

NameTypeDescription
rootstringThe directory to load the pieces from.

Returns​

AsyncIterableIterator<T>

An async iterator that yields the pieces to be loaded into the store.

Defined in​

projects/pieces/src/lib/structures/Store.ts:257


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: T, key: string, collection: Store<T>) => TFunction 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:226

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

Type parameters​

Name
This
T

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => T
thisArgThis

Returns​

T[]

Inherited from​

Collection.map

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:227


mapValues​

β–Έ mapValues<T>(fn): Collection<string, 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: T, key: string, collection: Store<T>) => TFunction that produces an element of the new collection, taking three arguments

Returns​

Collection<string, T>

Inherited from​

Collection.mapValues

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:238

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

Type parameters​

Name
This
T

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => T
thisArgThis

Returns​

Collection<string, T>

Inherited from​

Collection.mapValues

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:239


partition​

β–Έ partition<K2>(fn): [Collection<K2, T>, Collection<Exclude<string, K2>, T>]

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 string

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => key is K2Function used to test (should return a boolean)

Returns​

[Collection<K2, T>, Collection<Exclude<string, K2>, T>]

Inherited from​

Collection.partition

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:198

β–Έ partition<V2>(fn): [Collection<string, V2>, Collection<string, Exclude<T, V2>>]

Type parameters​

NameType
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2

Returns​

[Collection<string, V2>, Collection<string, Exclude<T, V2>>]

Inherited from​

Collection.partition

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:199

β–Έ partition(fn): [Collection<string, T>, Collection<string, T>]

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean

Returns​

[Collection<string, T>, Collection<string, T>]

Inherited from​

Collection.partition

Defined in​

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

β–Έ partition<This, K2>(fn, thisArg): [Collection<K2, T>, Collection<Exclude<string, K2>, T>]

Type parameters​

NameType
ThisThis
K2extends string

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => key is K2
thisArgThis

Returns​

[Collection<K2, T>, Collection<Exclude<string, K2>, T>]

Inherited from​

Collection.partition

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:201

β–Έ partition<This, V2>(fn, thisArg): [Collection<string, V2>, Collection<string, Exclude<T, V2>>]

Type parameters​

NameType
ThisThis
V2extends Piece<PieceOptions, V2>

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => value is V2
thisArgThis

Returns​

[Collection<string, V2>, Collection<string, Exclude<T, V2>>]

Inherited from​

Collection.partition

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:202

β–Έ partition<This>(fn, thisArg): [Collection<string, T>, Collection<string, T>]

Type parameters​

Name
This

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgThis

Returns​

[Collection<string, T>, Collection<string, T>]

Inherited from​

Collection.partition

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:203


random​

β–Έ random(): undefined | T

Obtains unique random value(s) from this collection.

Returns​

undefined | T

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): T[]

Parameters​

NameType
amountnumber

Returns​

T[]

Inherited from​

Collection.random

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:114


randomKey​

β–Έ randomKey(): undefined | string

Obtains unique random key(s) from this collection.

Returns​

undefined | string

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

β–Έ randomKey(amount): string[]

Parameters​

NameType
amountnumber

Returns​

string[]

Inherited from​

Collection.randomKey

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:123


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: T, key: string, collection: Store<T>) => 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/@discordjs/collection/dist/index.d.ts:279


registerPath​

β–Έ registerPath(path): Store<T>

Registers a directory into the store.

example

store
.registerPath(resolve('commands'))
.registerPath(resolve('third-party', 'commands'));

Parameters​

NameTypeDescription
pathstringThe path to be added.

Returns​

Store<T>

Defined in​

projects/pieces/src/lib/structures/Store.ts:88


resolve​

β–Έ resolve(name): T

Resolves a piece by its name or its instance.

Parameters​

NameTypeDescription
namestring | TThe name of the piece or the instance itself.

Returns​

T

The resolved piece.

Defined in​

projects/pieces/src/lib/structures/Store.ts:185


reverse​

β–Έ reverse(): Store<T>

Identical to Array.reverse() but returns a Collection instead of an Array.

Returns​

Store<T>

Inherited from​

Collection.reverse

Defined in​

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


set​

β–Έ set(key, value): Store<T>

Parameters​

NameType
keystring
valueT

Returns​

Store<T>

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: T, key: string, collection: Store<T>) => booleanFunction used to test (should return a boolean)

Returns​

boolean

Inherited from​

Collection.some

Defined in​

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

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

Type parameters​

Name
T

Parameters​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgT

Returns​

boolean

Inherited from​

Collection.some

Defined in​

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


sort​

β–Έ sort(compareFunction?): Store<T>

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<string, T>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​

Store<T>

Inherited from​

Collection.sort

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:347


sorted​

β–Έ sorted(compareFunction?): Collection<string, T>

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<string, T>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<string, T>

Inherited from​

Collection.sorted

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:372


sweep​

β–Έ sweep(fn): number

Removes items that satisfy the provided filter function.

Parameters​

NameTypeDescription
fn(value: T, key: string, collection: Store<T>) => booleanFunction 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​

NameType
fn(value: T, key: string, collection: Store<T>) => boolean
thisArgT

Returns​

number

Inherited from​

Collection.sweep

Defined in​

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


tap​

β–Έ tap(fn): Store<T>

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: Store<T>) => voidFunction to execute

Returns​

Store<T>

Inherited from​

Collection.tap

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:308

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

Type parameters​

Name
T

Parameters​

NameType
fn(collection: Store<T>) => void
thisArgT

Returns​

Store<T>

Inherited from​

Collection.tap

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:309


toJSON​

β–Έ toJSON(): T[]

Returns​

T[]

Inherited from​

Collection.toJSON

Defined in​

node_modules/@discordjs/collection/dist/index.d.ts:373


unload​

β–Έ unload(name): Promise<T>

Unloads a piece given its instance or its name.

Parameters​

NameTypeDescription
namestring | TThe name of the file to load.

Returns​

Promise<T>

Returns the piece that was unloaded.

Defined in​

projects/pieces/src/lib/structures/Store.ts:122


unloadAll​

β–Έ unloadAll(): Promise<T[]>

Unloads all pieces from the store.

Returns​

Promise<T[]>

Defined in​

projects/pieces/src/lib/structures/Store.ts:139


values​

β–Έ values(): IterableIterator<T>

Returns an iterable of values in the map

Returns​

IterableIterator<T>

Inherited from​

Collection.values

Defined in​

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


walk​

β–Έ Private walk(path): AsyncIterableIterator<string>

Retrieves all possible pieces.

Parameters​

NameTypeDescription
pathstringThe directory to load the pieces from.

Returns​

AsyncIterableIterator<string>

An async iterator that yields the modules to be processed and loaded into the store.

Defined in​

projects/pieces/src/lib/structures/Store.ts:281