mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Re-add docs
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Allows for the extension of built-in Discord.js structures that are instantiated by {@link DataStore DataStores}.
|
* Allows for the extension of built-in Discord.js structures that are instantiated by {@link DataStore DataStores}.
|
||||||
|
* When extending a built-in structure, it is important to both get the class you're extending from here,
|
||||||
|
* and to set it here afterwards.
|
||||||
*/
|
*/
|
||||||
class Structures {
|
class Structures {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -20,6 +22,17 @@ class Structures {
|
|||||||
* Replaces a structure class with an extended one.
|
* Replaces a structure class with an extended one.
|
||||||
* @param {string} structure Name of the structure to replace
|
* @param {string} structure Name of the structure to replace
|
||||||
* @param {Function} extended Extended structure class/prototype function to replace with
|
* @param {Function} extended Extended structure class/prototype function to replace with
|
||||||
|
* @example
|
||||||
|
* const { Structures } = require('discord.js');
|
||||||
|
*
|
||||||
|
* class CoolGuild extends Structures.get('Guild') {
|
||||||
|
* constructor(client, data) {
|
||||||
|
* super(client, data);
|
||||||
|
* this.cool = true;
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Structures.set('Guild', CoolGuild);
|
||||||
*/
|
*/
|
||||||
static set(structure, extended) {
|
static set(structure, extended) {
|
||||||
if (!structures[structure]) throw new RangeError(`"${structure}" is not a valid extensible structure.`);
|
if (!structures[structure]) throw new RangeError(`"${structure}" is not a valid extensible structure.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user