mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
Reimplement Structures.get
This commit is contained in:
parent
6d53d893a8
commit
f004e6ccca
2 changed files with 12 additions and 1 deletions
|
|
@ -9,7 +9,7 @@ class DataStore extends Collection {
|
|||
constructor(client, iterable, holds) {
|
||||
super();
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
Object.defineProperty(this, 'holds', { value: Structures.get(holds.name) });
|
||||
Object.defineProperty(this, 'holds', { value: Structures.get(holds) });
|
||||
if (iterable) for (const item of iterable) this.create(item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,17 @@ class Structures {
|
|||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a structure class.
|
||||
* @param {string|Function} structure Name of the structure or a class/prototype function to use the name of
|
||||
* @returns {Function}
|
||||
*/
|
||||
static get(structure) {
|
||||
if (typeof structure === 'string') return structures[structure];
|
||||
if (typeof structure === 'function') return structures[structure.name];
|
||||
throw new TypeError(`Structure to retrieve must be a string or class/prototype function, not ${typeof structure}.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends a structure.
|
||||
* @param {string} name Name of the structure class to extend
|
||||
|
|
|
|||
Loading…
Reference in a new issue