xernerx 2.7.4 → 3.0.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.
- package/LICENSE +21 -21
- package/README.md +0 -0
- package/dist/build/ContextCommand.d.ts +39 -0
- package/dist/build/ContextCommand.js +86 -0
- package/dist/build/Event.d.ts +15 -0
- package/dist/build/Event.js +31 -0
- package/dist/build/Inhibitor.d.ts +12 -0
- package/dist/build/Inhibitor.js +20 -0
- package/dist/build/MessageCommand.d.ts +39 -0
- package/dist/build/MessageCommand.js +77 -0
- package/dist/build/SlashCommand.d.ts +32 -0
- package/dist/build/SlashCommand.js +119 -0
- package/dist/client/XernerxClient.d.ts +22 -0
- package/dist/client/XernerxClient.js +76 -0
- package/dist/handlers/CommandHandler.d.ts +27 -0
- package/dist/handlers/CommandHandler.js +42 -0
- package/dist/handlers/EventHandler.d.ts +13 -0
- package/dist/handlers/EventHandler.js +16 -0
- package/dist/handlers/Handler.d.ts +37 -0
- package/dist/handlers/Handler.js +242 -0
- package/dist/handlers/InhibitorHandler.d.ts +18 -0
- package/dist/handlers/InhibitorHandler.js +21 -0
- package/dist/interfaces/ClientInterfaces.d.ts +58 -0
- package/dist/interfaces/ClientInterfaces.js +1 -0
- package/dist/interfaces/CommandInterfaces.d.ts +94 -0
- package/dist/interfaces/CommandInterfaces.js +1 -0
- package/dist/interfaces/HandlerInterfaces.d.ts +70 -0
- package/dist/interfaces/HandlerInterfaces.js +1 -0
- package/dist/main.d.ts +26 -0
- package/dist/main.js +40 -0
- package/dist/models/CommandArguments.d.ts +9 -0
- package/dist/models/CommandArguments.js +128 -0
- package/dist/models/CommandValidations.d.ts +3 -0
- package/dist/models/CommandValidations.js +193 -0
- package/dist/models/Events.d.ts +23 -0
- package/dist/models/Events.js +328 -0
- package/dist/models/Functions.d.ts +1 -0
- package/dist/models/Functions.js +30 -0
- package/dist/models/InhibitorValidations.d.ts +17 -0
- package/dist/models/InhibitorValidations.js +42 -0
- package/dist/types/EventTypes.d.ts +1 -0
- package/dist/types/EventTypes.js +1 -0
- package/dist/types/InhibitorTypes.d.ts +12 -0
- package/dist/types/InhibitorTypes.js +13 -0
- package/dist/types/Types.d.ts +24 -0
- package/dist/types/Types.js +21 -0
- package/dist/utils/ClientUtil.d.ts +25 -0
- package/dist/utils/ClientUtil.js +232 -0
- package/dist/utils/CommandUtil.d.ts +24 -0
- package/dist/utils/CommandUtil.js +163 -0
- package/package.json +5 -8
- package/main.js +0 -49
- package/models/Client.js +0 -60
- package/models/commands/ContextMenuCommand.js +0 -68
- package/models/commands/Event.js +0 -33
- package/models/commands/Inhibitor.js +0 -31
- package/models/commands/InteractionCommand.js +0 -142
- package/models/commands/MessageCommand.js +0 -86
- package/models/data/colors.json +0 -16
- package/models/data/options.json +0 -27
- package/models/events/interactionCreate.js +0 -84
- package/models/events/messageCreate.js +0 -84
- package/models/events/messageUpdate.js +0 -83
- package/models/events/readyOnce.js +0 -58
- package/models/handlers/CommandHandler.js +0 -37
- package/models/handlers/EventHandler.js +0 -67
- package/models/handlers/Handler.js +0 -111
- package/models/handlers/InhibitorHandler.js +0 -16
- package/models/handlers/LanguageHandler.js +0 -37
- package/models/utils/Arguments.js +0 -120
- package/models/utils/CommandValidation.js +0 -96
- package/models/utils/CommandsUtil.js +0 -70
- package/models/utils/Functions.js +0 -266
- package/models/utils/InhibitorsUtil.js +0 -24
- package/models/utils/InhibitorsValidation.js +0 -40
- package/models/utils/Util.js +0 -96
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Handler } from "./Handler.js";
|
|
2
|
+
import { CommandsDeploy, ContextCommandEvents, MessageCommandEvents, SlashCommandEvents, } from "../models/Events.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description - The command handler.
|
|
5
|
+
* @param {XernerxClient} client - The XernerxClient.
|
|
6
|
+
*/
|
|
7
|
+
export default class CommandHandler {
|
|
8
|
+
client;
|
|
9
|
+
handler;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.handler = new Handler(client);
|
|
13
|
+
new CommandsDeploy(this.client).deploy();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @description - The message command loader.
|
|
17
|
+
* @param {MessageCommandOptions} options - message command loader options.
|
|
18
|
+
*/
|
|
19
|
+
loadAllMessageCommands(options) {
|
|
20
|
+
this.handler.loadAllMessageCommands(options);
|
|
21
|
+
const events = new MessageCommandEvents(this.client);
|
|
22
|
+
events.messageCreate();
|
|
23
|
+
events.messageUpdate();
|
|
24
|
+
events.messageDelete();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @description - The slash command loader.
|
|
28
|
+
* @param {SlashCommandOptions} options - slash command loader options.
|
|
29
|
+
*/
|
|
30
|
+
loadAllSlashCommands(options) {
|
|
31
|
+
this.handler.loadAllSlashCommands(options);
|
|
32
|
+
new SlashCommandEvents(this.client).slashCreate();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @description - The context command loader.
|
|
36
|
+
* @param {ContextCommandOptions} options - context command loader options.
|
|
37
|
+
*/
|
|
38
|
+
loadAllContextCommands(options) {
|
|
39
|
+
this.handler.loadAllContextCommands(options);
|
|
40
|
+
new ContextCommandEvents(this.client).contextCreate();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventLoadOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
import XernerxClient from "../client/XernerxClient.js";
|
|
3
|
+
import { Handler } from "./Handler.js";
|
|
4
|
+
export default class EventHandler {
|
|
5
|
+
client: XernerxClient;
|
|
6
|
+
handler: Handler;
|
|
7
|
+
constructor(client: XernerxClient);
|
|
8
|
+
/**
|
|
9
|
+
* @description - The event loader
|
|
10
|
+
* @param {EventLoadOptions} options - message command options
|
|
11
|
+
*/
|
|
12
|
+
loadAllEvents(options: EventLoadOptions): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Handler } from "./Handler.js";
|
|
2
|
+
export default class EventHandler {
|
|
3
|
+
client;
|
|
4
|
+
handler;
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
this.handler = new Handler(client);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description - The event loader
|
|
11
|
+
* @param {EventLoadOptions} options - message command options
|
|
12
|
+
*/
|
|
13
|
+
loadAllEvents(options) {
|
|
14
|
+
this.handler.loadAllEvents(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import XernerxClient from "../client/XernerxClient.js";
|
|
2
|
+
import { ContextCommandOptions, MessageCommandOptions, SlashCommandOptions, EventLoadOptions, InhibitorLoadOptions } from "../interfaces/HandlerInterfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* @description - The Handler class.
|
|
5
|
+
* @param {XernerxClient} client - The XernerxClient.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Handler {
|
|
8
|
+
#private;
|
|
9
|
+
client: XernerxClient;
|
|
10
|
+
commands: object[];
|
|
11
|
+
constructor(client: XernerxClient);
|
|
12
|
+
/**
|
|
13
|
+
* @description - The loader for the message commands.
|
|
14
|
+
* @param {MessageCommandOptions} options - The options for the message command loader.
|
|
15
|
+
*/
|
|
16
|
+
loadAllMessageCommands(options: MessageCommandOptions): void;
|
|
17
|
+
/**
|
|
18
|
+
* @description - The loader for the slash commands.
|
|
19
|
+
* @param {SlashCommandOptions} options - The options for the slash command loader.
|
|
20
|
+
*/
|
|
21
|
+
loadAllSlashCommands(options: SlashCommandOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* @description - The loader for the context commands.
|
|
24
|
+
* @param {ContextCommandOptions} options - The options for the context command loader.
|
|
25
|
+
*/
|
|
26
|
+
loadAllContextCommands(options: ContextCommandOptions): void;
|
|
27
|
+
/**
|
|
28
|
+
* @description - The loader for the events.
|
|
29
|
+
* @param {EventLoadOptions} options - The options for the event loader.
|
|
30
|
+
*/
|
|
31
|
+
loadAllEvents(options: EventLoadOptions): void;
|
|
32
|
+
/**
|
|
33
|
+
* @description - The loader for the inhibitors.
|
|
34
|
+
* @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
|
|
35
|
+
*/
|
|
36
|
+
loadAllInhibitors(options: InhibitorLoadOptions): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { CommandType } from "../types/Types.js";
|
|
4
|
+
import { s } from "@sapphire/shapeshift";
|
|
5
|
+
import { logStyle } from "../models/Functions.js";
|
|
6
|
+
/**
|
|
7
|
+
* @description - The Handler class.
|
|
8
|
+
* @param {XernerxClient} client - The XernerxClient.
|
|
9
|
+
*/
|
|
10
|
+
export class Handler {
|
|
11
|
+
client;
|
|
12
|
+
commands;
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
this.commands = [];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description - The loader for the message commands.
|
|
19
|
+
* @param {MessageCommandOptions} options - The options for the message command loader.
|
|
20
|
+
*/
|
|
21
|
+
loadAllMessageCommands(options) {
|
|
22
|
+
this.client.handlerOptions.message = s
|
|
23
|
+
.object({
|
|
24
|
+
directory: s.string,
|
|
25
|
+
prefix: s.union(s.string, s.array(s.string)),
|
|
26
|
+
allowMention: s.boolean.default(false),
|
|
27
|
+
cooldown: s.number.default(0),
|
|
28
|
+
userPermissions: s.array(s.bigint).default([]),
|
|
29
|
+
clientPermissions: s.array(s.bigint).default([]),
|
|
30
|
+
handleEdits: s.boolean.default(false),
|
|
31
|
+
handleDeletes: s.boolean.default(false),
|
|
32
|
+
logging: s.boolean.default(false),
|
|
33
|
+
})
|
|
34
|
+
.parse(options);
|
|
35
|
+
const files = this.#readdir(options.directory), loaded = [];
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
this.#load(options.directory, file, CommandType.MessageCommand);
|
|
38
|
+
loaded.push(file.replace(".js", ""));
|
|
39
|
+
}
|
|
40
|
+
if (this.client.handlerOptions.message.logging)
|
|
41
|
+
console.info(logStyle(`Xernerx | Loaded ${loaded.length} message commands: ${loaded.join(", ")}.`, "text", "cyan"));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @description - The loader for the slash commands.
|
|
45
|
+
* @param {SlashCommandOptions} options - The options for the slash command loader.
|
|
46
|
+
*/
|
|
47
|
+
loadAllSlashCommands(options) {
|
|
48
|
+
this.client.handlerOptions.slash = s
|
|
49
|
+
.object({
|
|
50
|
+
directory: s.string,
|
|
51
|
+
guildId: s.string,
|
|
52
|
+
global: s.boolean,
|
|
53
|
+
cooldown: s.number.default(0),
|
|
54
|
+
userPermissions: s.array(s.bigint).default([]),
|
|
55
|
+
clientPermissions: s.array(s.bigint).default([]),
|
|
56
|
+
logging: s.boolean.default(false),
|
|
57
|
+
defer: s.object({
|
|
58
|
+
reply: s.boolean.optional,
|
|
59
|
+
ephemeral: s.boolean.optional,
|
|
60
|
+
fetchReply: s.boolean.optional,
|
|
61
|
+
}).optional,
|
|
62
|
+
})
|
|
63
|
+
.parse(options);
|
|
64
|
+
const files = this.#readdir(options.directory), loaded = [];
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
this.#load(options.directory, file, CommandType.SlashCommand);
|
|
67
|
+
loaded.push(file.replace(".js", ""));
|
|
68
|
+
}
|
|
69
|
+
if (this.client.handlerOptions.slash.logging)
|
|
70
|
+
console.info(logStyle(`Xernerx | Loaded ${loaded.length} slash commands: ${loaded.join(", ")}.`, "text", "cyan"));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @description - The loader for the context commands.
|
|
74
|
+
* @param {ContextCommandOptions} options - The options for the context command loader.
|
|
75
|
+
*/
|
|
76
|
+
loadAllContextCommands(options) {
|
|
77
|
+
this.client.handlerOptions.context = s
|
|
78
|
+
.object({
|
|
79
|
+
directory: s.string,
|
|
80
|
+
guildId: s.string,
|
|
81
|
+
global: s.boolean,
|
|
82
|
+
cooldown: s.number.default(0),
|
|
83
|
+
userPermissions: s.array(s.bigint).default([]),
|
|
84
|
+
clientPermissions: s.array(s.bigint).default([]),
|
|
85
|
+
logging: s.boolean.default(false),
|
|
86
|
+
defer: s.object({
|
|
87
|
+
reply: s.boolean.optional,
|
|
88
|
+
ephemeral: s.boolean.optional,
|
|
89
|
+
fetchReply: s.boolean.optional,
|
|
90
|
+
}).optional,
|
|
91
|
+
})
|
|
92
|
+
.parse(options);
|
|
93
|
+
const files = this.#readdir(options.directory), loaded = [];
|
|
94
|
+
for (const file of files) {
|
|
95
|
+
this.#load(options.directory, file, CommandType.ContextCommand);
|
|
96
|
+
loaded.push(file.replace(".js", ""));
|
|
97
|
+
}
|
|
98
|
+
if (this.client.handlerOptions.context.logging)
|
|
99
|
+
console.info(logStyle(`Xernerx | Loaded ${loaded.length} context commands: ${loaded.join(", ")}.`, "text", "cyan"));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @description - The loader for the events.
|
|
103
|
+
* @param {EventLoadOptions} options - The options for the event loader.
|
|
104
|
+
*/
|
|
105
|
+
loadAllEvents(options) {
|
|
106
|
+
this.client.handlerOptions.events = s
|
|
107
|
+
.object({
|
|
108
|
+
directory: s.string,
|
|
109
|
+
logging: s.boolean.default(false),
|
|
110
|
+
})
|
|
111
|
+
.parse(options);
|
|
112
|
+
const files = this.#readdir(options.directory), loaded = [];
|
|
113
|
+
(async () => {
|
|
114
|
+
for (const file of files) {
|
|
115
|
+
try {
|
|
116
|
+
options.directory.split(/\//).shift();
|
|
117
|
+
let event = (await import("file://" + `${path.resolve(options.directory)}/${file}`)).default;
|
|
118
|
+
event = new event();
|
|
119
|
+
event.client = this.client;
|
|
120
|
+
event.commandType = CommandType.Event;
|
|
121
|
+
this.client.events.set(event.name, event);
|
|
122
|
+
this.#emitter(event);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error(logStyle(`Xernerx | Couldn't load ${file} because <${error}>`, "background", "red"));
|
|
126
|
+
}
|
|
127
|
+
loaded.push(file.replace(".js", ""));
|
|
128
|
+
}
|
|
129
|
+
if (this.client.handlerOptions.events?.logging)
|
|
130
|
+
console.info(logStyle(`Xernerx | Loaded ${loaded.length} events: ${loaded.join(", ")}.`, "text", "cyan"));
|
|
131
|
+
})();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @description - The loader for the inhibitors.
|
|
135
|
+
* @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
|
|
136
|
+
*/
|
|
137
|
+
loadAllInhibitors(options) {
|
|
138
|
+
this.client.handlerOptions.inhibitors = s
|
|
139
|
+
.object({
|
|
140
|
+
directory: s.string,
|
|
141
|
+
logging: s.boolean.default(false),
|
|
142
|
+
})
|
|
143
|
+
.parse(options);
|
|
144
|
+
const files = this.#readdir(options.directory), loaded = [];
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
this.#load(options.directory, file, CommandType.Inhibitor);
|
|
147
|
+
loaded.push(file.replace(".js", ""));
|
|
148
|
+
}
|
|
149
|
+
if (this.client.handlerOptions.inhibitors?.logging)
|
|
150
|
+
console.info(logStyle(`Xernerx | Loaded ${loaded.length} inhibitors: ${loaded.join(", ")}.`, "text", "cyan"));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @description - a reader for directories
|
|
154
|
+
* @param {string} dir - the directory to look for.
|
|
155
|
+
* @returns array of files.
|
|
156
|
+
*/
|
|
157
|
+
#readdir(dir) {
|
|
158
|
+
try {
|
|
159
|
+
return fs
|
|
160
|
+
.readdirSync(path.resolve(dir))
|
|
161
|
+
.filter((file) => file.endsWith(".js"));
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error(logStyle(`Xernerx | Couldn't read ${dir} because <${error}>.`, "background", "red"));
|
|
165
|
+
}
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @description file loader.
|
|
170
|
+
* @param {string} dir - the directory.
|
|
171
|
+
* @param {string} file - the file in the directory.
|
|
172
|
+
* @param {string} type - the type of file.
|
|
173
|
+
* @returns undefined
|
|
174
|
+
*/
|
|
175
|
+
async #load(dir, file, type) {
|
|
176
|
+
try {
|
|
177
|
+
dir.split(/\//).shift();
|
|
178
|
+
let command = (await import("file://" + `${path.resolve(dir)}/${file}`))
|
|
179
|
+
.default;
|
|
180
|
+
command = new command();
|
|
181
|
+
command.client = this.client;
|
|
182
|
+
command.commandType = type;
|
|
183
|
+
command.filepath = `${path.resolve(dir)}\\${file}`;
|
|
184
|
+
command.file = file;
|
|
185
|
+
if (type === CommandType.MessageCommand)
|
|
186
|
+
this.client.commands.message.set(command?.name || command?.name, command);
|
|
187
|
+
if (type === CommandType.SlashCommand) {
|
|
188
|
+
this.client.commands.slash.set(command?.data?.name || command?.name, command);
|
|
189
|
+
}
|
|
190
|
+
if (type === CommandType.ContextCommand) {
|
|
191
|
+
this.client.commands.context.set(command?.data?.name || command?.name, command);
|
|
192
|
+
}
|
|
193
|
+
if (type === CommandType.Event) {
|
|
194
|
+
this.client.events.set(command.name, command);
|
|
195
|
+
}
|
|
196
|
+
if (type === CommandType.Inhibitor) {
|
|
197
|
+
this.client.inhibitors.set(command.name, command);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
console.error(logStyle(`Xernerx | Couldn't load ${file} because <${error}>.`, "background", "red"));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @description the event emitter to emit all events.
|
|
206
|
+
* @param {object} event - the event to be emitted.
|
|
207
|
+
* @returns void
|
|
208
|
+
*/
|
|
209
|
+
#emitter(event) {
|
|
210
|
+
const client = this.client;
|
|
211
|
+
if (event.emitter === "client") {
|
|
212
|
+
if (event.once)
|
|
213
|
+
client.once(event.name, (...args) => {
|
|
214
|
+
event.run(...args);
|
|
215
|
+
});
|
|
216
|
+
else
|
|
217
|
+
client.on(event.name, (...args) => {
|
|
218
|
+
event.run(...args);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else if (event.emitter === "rest") {
|
|
222
|
+
if (event.once)
|
|
223
|
+
client.once(event.name, (...args) => {
|
|
224
|
+
event.run(...args);
|
|
225
|
+
});
|
|
226
|
+
else
|
|
227
|
+
client.on(event.name, (...args) => {
|
|
228
|
+
event.run(...args);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
else if (event.emitter === "process") {
|
|
232
|
+
if (event.once)
|
|
233
|
+
process.once(event.name, (...args) => {
|
|
234
|
+
event.run(...args);
|
|
235
|
+
});
|
|
236
|
+
else
|
|
237
|
+
process.on(event.name, (...args) => {
|
|
238
|
+
event.run(...args);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InhibitorLoadOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
import XernerxClient from "../client/XernerxClient.js";
|
|
3
|
+
import { Handler } from "./Handler.js";
|
|
4
|
+
/**
|
|
5
|
+
* @description - Inhibitor loader.
|
|
6
|
+
* @param {XernerxClient} client - The XernerxClient.
|
|
7
|
+
*/
|
|
8
|
+
export default class InhibitorHandler {
|
|
9
|
+
client: XernerxClient;
|
|
10
|
+
handler: Handler;
|
|
11
|
+
constructor(client: XernerxClient);
|
|
12
|
+
/**
|
|
13
|
+
* @description - The loader for all inhibitors.
|
|
14
|
+
* @param {InhibitorLoadOptions} options - the inhibitor loader options.
|
|
15
|
+
* @returns undefined
|
|
16
|
+
*/
|
|
17
|
+
loadAllInhibitors(options: InhibitorLoadOptions): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Handler } from "./Handler.js";
|
|
2
|
+
/**
|
|
3
|
+
* @description - Inhibitor loader.
|
|
4
|
+
* @param {XernerxClient} client - The XernerxClient.
|
|
5
|
+
*/
|
|
6
|
+
export default class InhibitorHandler {
|
|
7
|
+
client;
|
|
8
|
+
handler;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
this.handler = new Handler(client);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @description - The loader for all inhibitors.
|
|
15
|
+
* @param {InhibitorLoadOptions} options - the inhibitor loader options.
|
|
16
|
+
* @returns undefined
|
|
17
|
+
*/
|
|
18
|
+
loadAllInhibitors(options) {
|
|
19
|
+
this.handler.loadAllInhibitors(options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CacheFactory, Collection, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from "discord.js";
|
|
2
|
+
import CommandHandler from "../handlers/CommandHandler.js";
|
|
3
|
+
import EventHandler from "../handlers/EventHandler.js";
|
|
4
|
+
import InhibitorHandler from "../handlers/InhibitorHandler.js";
|
|
5
|
+
import { ContextCommandOptions, MessageCommandOptions, SlashCommandOptions, EventLoadOptions, InhibitorLoadOptions } from "./HandlerInterfaces.js";
|
|
6
|
+
import { MessageCommand } from "../build/MessageCommand.js";
|
|
7
|
+
export interface DiscordOptions {
|
|
8
|
+
shards?: number | number[] | "auto";
|
|
9
|
+
closeTimeout?: number;
|
|
10
|
+
shardCount?: number;
|
|
11
|
+
makeCache?: CacheFactory;
|
|
12
|
+
allowedMentions?: MessageMentionOptions;
|
|
13
|
+
partials?: Array<Partials>;
|
|
14
|
+
failIfNotExists?: boolean;
|
|
15
|
+
presence?: PresenceData;
|
|
16
|
+
intents: number[];
|
|
17
|
+
waitGuildTimeout?: number;
|
|
18
|
+
sweepers?: SweeperOptions;
|
|
19
|
+
ws?: WebSocketOptions;
|
|
20
|
+
rest?: RESTOptions;
|
|
21
|
+
jsonTransformer?: (obj: unknown) => unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface ClientOptions {
|
|
24
|
+
ownerId?: string | string[];
|
|
25
|
+
clientPermissions?: bigint[];
|
|
26
|
+
userPermissions?: bigint[];
|
|
27
|
+
ignoreOwner?: boolean;
|
|
28
|
+
logging?: boolean;
|
|
29
|
+
cooldown?: {
|
|
30
|
+
default?: number;
|
|
31
|
+
cache?: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface HandlerOptions {
|
|
35
|
+
message?: MessageCommandOptions;
|
|
36
|
+
slash?: SlashCommandOptions;
|
|
37
|
+
context?: ContextCommandOptions;
|
|
38
|
+
events?: EventLoadOptions;
|
|
39
|
+
inhibitors?: InhibitorLoadOptions;
|
|
40
|
+
}
|
|
41
|
+
export interface Commands {
|
|
42
|
+
message: Collection<string, MessageCommand>;
|
|
43
|
+
slash: Collection<string, object>;
|
|
44
|
+
context: Collection<string, object>;
|
|
45
|
+
}
|
|
46
|
+
export interface Cache {
|
|
47
|
+
messages: Collection<string, object>;
|
|
48
|
+
cooldowns: Collection<string, object>;
|
|
49
|
+
messageCommands: Collection<string, object>;
|
|
50
|
+
slashCommands: Collection<string, object>;
|
|
51
|
+
contextCommands: Collection<string, object>;
|
|
52
|
+
commands: Collection<string, object>;
|
|
53
|
+
}
|
|
54
|
+
export interface Modules {
|
|
55
|
+
commandHandler: CommandHandler;
|
|
56
|
+
eventHandler: EventHandler;
|
|
57
|
+
inhibitorHandler: InhibitorHandler;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ChannelType, ContextMenuCommandType } from "discord.js";
|
|
2
|
+
export interface MessageCommandOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
regex?: string;
|
|
5
|
+
aliases?: string[];
|
|
6
|
+
description?: string;
|
|
7
|
+
prefix?: string | string[];
|
|
8
|
+
info?: string;
|
|
9
|
+
category?: string;
|
|
10
|
+
owner?: boolean;
|
|
11
|
+
channelType?: ChannelType | ChannelType[];
|
|
12
|
+
separator?: string;
|
|
13
|
+
cooldown?: number;
|
|
14
|
+
ignoreOwner?: boolean;
|
|
15
|
+
channels?: string[];
|
|
16
|
+
guilds?: string[];
|
|
17
|
+
userPermissions?: bigint[];
|
|
18
|
+
clientPermissions?: bigint[];
|
|
19
|
+
commandType?: string;
|
|
20
|
+
args: object[];
|
|
21
|
+
}
|
|
22
|
+
export interface ContextCommandOptions {
|
|
23
|
+
name: string;
|
|
24
|
+
type: ContextMenuCommandType | number;
|
|
25
|
+
description?: string;
|
|
26
|
+
info?: string;
|
|
27
|
+
category?: string;
|
|
28
|
+
owner?: boolean;
|
|
29
|
+
channelType?: ChannelType;
|
|
30
|
+
separator?: string;
|
|
31
|
+
cooldown?: number;
|
|
32
|
+
ignoreOwner?: boolean;
|
|
33
|
+
channels?: string[];
|
|
34
|
+
guilds?: string[];
|
|
35
|
+
userPermissions?: bigint[];
|
|
36
|
+
clientPermissions?: bigint[];
|
|
37
|
+
defaultMemberPermissions?: bigint | number | bigint | null | undefined;
|
|
38
|
+
DMPermission?: undefined | null | boolean;
|
|
39
|
+
nameLocalization?: {
|
|
40
|
+
locale: "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi";
|
|
41
|
+
localizedName: null | string;
|
|
42
|
+
};
|
|
43
|
+
nameLocalizations?: null | Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>;
|
|
44
|
+
commandType?: string;
|
|
45
|
+
defer?: {
|
|
46
|
+
reply?: boolean;
|
|
47
|
+
ephemeral?: boolean;
|
|
48
|
+
fetchReply?: boolean;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface SlashArg {
|
|
52
|
+
type: "string" | "number" | "boolean" | "user" | "channel" | "role" | "mentionable" | "integer";
|
|
53
|
+
name: string;
|
|
54
|
+
choices: Array<{
|
|
55
|
+
name: string;
|
|
56
|
+
value: string;
|
|
57
|
+
}>;
|
|
58
|
+
required: boolean;
|
|
59
|
+
description: string;
|
|
60
|
+
}
|
|
61
|
+
export interface SlashSubcommand {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
args: Array<SlashArg>;
|
|
65
|
+
}
|
|
66
|
+
export interface SlashGroup {
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
subcommands: Array<SlashSubcommand>;
|
|
70
|
+
}
|
|
71
|
+
export interface SlashCommandOptions {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
info?: string;
|
|
75
|
+
category?: string;
|
|
76
|
+
owner?: boolean;
|
|
77
|
+
channelType?: ChannelType;
|
|
78
|
+
separator?: string;
|
|
79
|
+
cooldown?: number;
|
|
80
|
+
ignoreOwner?: boolean;
|
|
81
|
+
channels?: string[];
|
|
82
|
+
guilds?: string[];
|
|
83
|
+
userPermissions?: bigint[];
|
|
84
|
+
clientPermissions?: bigint[];
|
|
85
|
+
args?: Array<SlashArg>;
|
|
86
|
+
subcommands?: Array<SlashSubcommand>;
|
|
87
|
+
groups?: Array<SlashGroup>;
|
|
88
|
+
commandType?: string;
|
|
89
|
+
defer?: {
|
|
90
|
+
reply?: boolean;
|
|
91
|
+
ephemeral?: boolean;
|
|
92
|
+
fetchReply?: boolean;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Message, User } from "discord.js";
|
|
2
|
+
import { EventEmitterType } from "../types/Types.js";
|
|
3
|
+
import { MessageCommandUtil } from "../utils/CommandUtil.js";
|
|
4
|
+
export interface MessageCommandOptions {
|
|
5
|
+
directory: string;
|
|
6
|
+
prefix: string[] | string;
|
|
7
|
+
allowMention?: boolean;
|
|
8
|
+
cooldown?: number;
|
|
9
|
+
userPermissions?: bigint[];
|
|
10
|
+
clientPermissions?: bigint[];
|
|
11
|
+
handleEdits?: boolean;
|
|
12
|
+
handleDeletes?: boolean;
|
|
13
|
+
util?: boolean;
|
|
14
|
+
logging?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SlashCommandOptions {
|
|
17
|
+
directory: string;
|
|
18
|
+
guildId: string;
|
|
19
|
+
global: boolean;
|
|
20
|
+
cooldown?: number;
|
|
21
|
+
userPermissions?: bigint[];
|
|
22
|
+
clientPermissions?: bigint[];
|
|
23
|
+
util?: boolean;
|
|
24
|
+
logging?: boolean;
|
|
25
|
+
defer?: {
|
|
26
|
+
reply?: boolean;
|
|
27
|
+
ephemeral?: boolean;
|
|
28
|
+
fetchReply?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ContextCommandOptions {
|
|
32
|
+
directory: string;
|
|
33
|
+
guildId: string;
|
|
34
|
+
global: boolean;
|
|
35
|
+
cooldown?: number;
|
|
36
|
+
userPermissions?: bigint[];
|
|
37
|
+
clientPermissions?: bigint[];
|
|
38
|
+
util?: boolean;
|
|
39
|
+
logging?: boolean;
|
|
40
|
+
defer?: {
|
|
41
|
+
reply?: boolean;
|
|
42
|
+
ephemeral?: boolean;
|
|
43
|
+
fetchReply?: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface EventLoadOptions {
|
|
47
|
+
directory: string;
|
|
48
|
+
logging?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface EventOptions {
|
|
51
|
+
name: string;
|
|
52
|
+
emitter?: EventEmitterType;
|
|
53
|
+
type?: string;
|
|
54
|
+
once?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface InhibitorLoadOptions {
|
|
57
|
+
directory: string;
|
|
58
|
+
logging?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface InhibitorOptions {
|
|
61
|
+
name: string;
|
|
62
|
+
type: string;
|
|
63
|
+
}
|
|
64
|
+
export interface XernerxMessage extends Message {
|
|
65
|
+
util?: MessageCommandUtil;
|
|
66
|
+
response?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface XernerxUser extends User {
|
|
69
|
+
isOwner: boolean;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Discord from "discord.js";
|
|
2
|
+
import XernerxClient from "./client/XernerxClient.js";
|
|
3
|
+
import { Event } from "./build/Event.js";
|
|
4
|
+
import { Inhibitor } from "./build/Inhibitor.js";
|
|
5
|
+
import { MessageCommand } from "./build/MessageCommand.js";
|
|
6
|
+
import { ContextCommand } from "./build/ContextCommand.js";
|
|
7
|
+
import { SlashCommand } from "./build/SlashCommand.js";
|
|
8
|
+
import { CommandType, EventEmitterType } from "./types/Types.js";
|
|
9
|
+
import { InhibitorType } from "./types/InhibitorTypes.js";
|
|
10
|
+
declare const version: string;
|
|
11
|
+
declare const _default: {
|
|
12
|
+
Discord: typeof Discord;
|
|
13
|
+
Client: typeof XernerxClient;
|
|
14
|
+
XernerxClient: typeof XernerxClient;
|
|
15
|
+
CommandType: typeof CommandType;
|
|
16
|
+
EventEmitterType: typeof EventEmitterType;
|
|
17
|
+
InhibitorType: typeof InhibitorType;
|
|
18
|
+
Event: typeof Event;
|
|
19
|
+
MessageCommand: typeof MessageCommand;
|
|
20
|
+
ContextCommand: typeof ContextCommand;
|
|
21
|
+
SlashCommand: typeof SlashCommand;
|
|
22
|
+
Inhibitor: typeof Inhibitor;
|
|
23
|
+
version: string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
26
|
+
export { Discord, XernerxClient, CommandType, EventEmitterType, InhibitorType, Event, MessageCommand, ContextCommand, SlashCommand, Inhibitor, version, };
|