xernerx 3.1.4 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client, Collection } from "discord.js";
|
|
2
2
|
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
3
|
-
import { DiscordOptions, ClientOptions, Commands, Cache, Modules, HandlerOptions } from "../interfaces/ClientInterfaces.js";
|
|
3
|
+
import { DiscordOptions, ClientOptions, Commands, Cache, Modules, HandlerOptions, ExtensionOptions } from "../interfaces/ClientInterfaces.js";
|
|
4
4
|
/**
|
|
5
5
|
* @description - The Client.
|
|
6
6
|
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
@@ -15,8 +15,10 @@ export default class XernerxClient extends Client {
|
|
|
15
15
|
util: ClientUtil;
|
|
16
16
|
handlerOptions: HandlerOptions;
|
|
17
17
|
events: Collection<string, object>;
|
|
18
|
+
extensions: Record<string, object>;
|
|
18
19
|
inhibitors: Collection<string, object>;
|
|
19
20
|
config: object;
|
|
20
21
|
constructor(discordOptions: DiscordOptions, clientOptions: ClientOptions, config?: object);
|
|
21
22
|
register(token: string): void;
|
|
23
|
+
loadExtensions(options: ExtensionOptions): Promise<void>;
|
|
22
24
|
}
|
|
@@ -6,6 +6,7 @@ import InhibitorHandler from "../handlers/InhibitorHandler.js";
|
|
|
6
6
|
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
7
7
|
import { Style } from "dumfunctions";
|
|
8
8
|
import WebhookHandler from "../handlers/WebhookHandler.js";
|
|
9
|
+
import Extensions from "../models/Extensions.js";
|
|
9
10
|
/**
|
|
10
11
|
* @description - The Client.
|
|
11
12
|
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
@@ -20,6 +21,7 @@ export default class XernerxClient extends Client {
|
|
|
20
21
|
util;
|
|
21
22
|
handlerOptions;
|
|
22
23
|
events;
|
|
24
|
+
extensions;
|
|
23
25
|
inhibitors;
|
|
24
26
|
config;
|
|
25
27
|
constructor(discordOptions, clientOptions, config) {
|
|
@@ -59,6 +61,7 @@ export default class XernerxClient extends Client {
|
|
|
59
61
|
inhibitorHandler: new InhibitorHandler(this),
|
|
60
62
|
webhookHandler: new WebhookHandler(this),
|
|
61
63
|
};
|
|
64
|
+
this.extensions = {};
|
|
62
65
|
this.util = new ClientUtil(this);
|
|
63
66
|
this.handlerOptions = {};
|
|
64
67
|
if (this.settings.logging) {
|
|
@@ -72,4 +75,8 @@ export default class XernerxClient extends Client {
|
|
|
72
75
|
register(token) {
|
|
73
76
|
this.login(token);
|
|
74
77
|
}
|
|
78
|
+
loadExtensions(options) {
|
|
79
|
+
const extensions = new Extensions(this);
|
|
80
|
+
return extensions.load(options.extensions, options.logging || false);
|
|
81
|
+
}
|
|
75
82
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Style } from "dumfunctions";
|
|
2
|
+
export default class Extensions {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
async load(extensions, logging = false) {
|
|
8
|
+
const exts = [];
|
|
9
|
+
extensions.map(extension => {
|
|
10
|
+
this.client.extensions[extension.name] = new extension(this.client, logging);
|
|
11
|
+
exts.push(extension.name);
|
|
12
|
+
});
|
|
13
|
+
if (logging)
|
|
14
|
+
console.info(Style.log(`Xernerx | Loaded ${exts.length} extensions: ${exts.join(', ')}`, { color: Style.TextColor.Cyan }));
|
|
15
|
+
}
|
|
16
|
+
}
|