xernerx 4.5.22 → 4.5.26
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/README.md +3 -0
- package/dist/build/XernerxContextCommand.d.ts +42 -50
- package/dist/build/XernerxContextCommand.js +71 -71
- package/dist/build/XernerxEvent.d.ts +15 -15
- package/dist/build/XernerxEvent.js +22 -22
- package/dist/build/XernerxInhibitor.d.ts +14 -25
- package/dist/build/XernerxInhibitor.js +20 -20
- package/dist/build/XernerxMessageCommand.d.ts +47 -53
- package/dist/build/XernerxMessageCommand.js +70 -70
- package/dist/build/XernerxSlashCommand.d.ts +57 -71
- package/dist/build/XernerxSlashCommand.js +128 -128
- package/dist/client/XernerxClient.d.ts +40 -48
- package/dist/client/XernerxClient.js +77 -77
- package/dist/client/XernerxShardClient.d.ts +12 -12
- package/dist/client/XernerxShardClient.js +39 -47
- package/dist/functions/deploy.d.ts +1 -1
- package/dist/functions/deploy.js +36 -31
- package/dist/functions/load.d.ts +1 -1
- package/dist/functions/load.js +29 -28
- package/dist/functions/reload.d.ts +1 -1
- package/dist/functions/reload.js +38 -35
- package/dist/functions/sendWebhook.d.ts +1 -1
- package/dist/functions/sendWebhook.js +12 -11
- package/dist/functions/setPresence.d.ts +2 -2
- package/dist/functions/setPresence.js +17 -18
- package/dist/functions/xernerxUser.d.ts +1 -1
- package/dist/functions/xernerxUser.js +6 -6
- package/dist/handlers/CommandHandler.d.ts +9 -9
- package/dist/handlers/CommandHandler.d.ts.map +1 -1
- package/dist/handlers/CommandHandler.js +281 -249
- package/dist/handlers/CommandHandler.js.map +1 -1
- package/dist/handlers/EventHandler.d.ts +3 -3
- package/dist/handlers/EventHandler.js +19 -19
- package/dist/handlers/ExtensionHandler.d.ts +3 -3
- package/dist/handlers/ExtensionHandler.js +20 -18
- package/dist/handlers/Handler.d.ts +8 -8
- package/dist/handlers/Handler.js +42 -32
- package/dist/handlers/InhibitorHandler.d.ts +3 -3
- package/dist/handlers/InhibitorHandler.js +19 -19
- package/dist/handlers/WebhookHandler.d.ts +6 -4
- package/dist/handlers/WebhookHandler.js +44 -47
- package/dist/main.d.ts +22 -29
- package/dist/main.js +22 -29
- package/dist/models/Arguments.d.ts +2 -5
- package/dist/models/Arguments.js +150 -135
- package/dist/tools/XernerxError.d.ts +5 -5
- package/dist/tools/XernerxError.js +9 -9
- package/dist/tools/XernerxLog.d.ts +13 -13
- package/dist/tools/XernerxLog.js +69 -74
- package/dist/tools/XernerxText.d.ts +23 -23
- package/dist/tools/XernerxText.js +85 -76
- package/dist/types/extenders.d.ts +36 -44
- package/dist/types/extenders.js +1 -1
- package/dist/types/interfaces.d.ts +182 -185
- package/dist/types/interfaces.js +1 -1
- package/dist/types/types.d.ts +7 -179
- package/dist/types/types.js +1 -1
- package/dist/utils/ClientUtil.d.ts +9 -11
- package/dist/utils/ClientUtil.js +73 -57
- package/dist/utils/InteractionUtil.d.ts +7 -7
- package/dist/utils/InteractionUtil.js +98 -96
- package/dist/utils/MessageUtil.d.ts +11 -11
- package/dist/utils/MessageUtil.js +135 -130
- package/dist/utils/Util.d.ts +5 -5
- package/dist/utils/Util.js +8 -8
- package/dist/validators/commandValidation.d.ts +2 -5
- package/dist/validators/commandValidation.js +53 -43
- package/dist/validators/inhibitorValidations.d.ts +3 -19
- package/dist/validators/inhibitorValidations.js +31 -31
- package/package.json +16 -13
|
@@ -3,13 +3,13 @@ import XernerxClient from '../client/XernerxClient.js';
|
|
|
3
3
|
import { ContextHandlerOptions, MessageHandlerOptions, SlashHandlerOptions } from '../types/interfaces.js';
|
|
4
4
|
import Handler from './Handler.js';
|
|
5
5
|
export default class CommandHandler extends Handler {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
constructor(client: XernerxClient);
|
|
7
|
+
loadMessageCommands(options: MessageHandlerOptions): void;
|
|
8
|
+
loadSlashCommands(options: SlashHandlerOptions): void;
|
|
9
|
+
loadContextCommands(options: ContextHandlerOptions): void;
|
|
10
|
+
private messageCommandRun;
|
|
11
|
+
private slashCommandRun;
|
|
12
|
+
private contextCommandRun;
|
|
13
|
+
private exec;
|
|
14
14
|
}
|
|
15
|
-
//# sourceMappingURL=CommandHandler.d.ts.map
|
|
15
|
+
//# sourceMappingURL=CommandHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/CommandHandler.ts"],"names":[],"mappings":"AAAA,cAAc;AAMd,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,OAAO,MAAM,cAAc,CAAC;AAenC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;gBACtC,MAAM,EAAE,aAAa;IAI1B,mBAAmB,CAAC,OAAO,EAAE,qBAAqB;IA2DlD,iBAAiB,CAAC,OAAO,EAAE,mBAAmB;IA4C9C,mBAAmB,CAAC,OAAO,EAAE,qBAAqB;YA4C3C,iBAAiB;
|
|
1
|
+
{"version":3,"file":"CommandHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/CommandHandler.ts"],"names":[],"mappings":"AAAA,cAAc;AAMd,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,OAAO,MAAM,cAAc,CAAC;AAenC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;gBACtC,MAAM,EAAE,aAAa;IAI1B,mBAAmB,CAAC,OAAO,EAAE,qBAAqB;IA2DlD,iBAAiB,CAAC,OAAO,EAAE,mBAAmB;IA4C9C,mBAAmB,CAAC,OAAO,EAAE,qBAAqB;YA4C3C,iBAAiB;YA8HjB,eAAe;YA+Bf,iBAAiB;YAoBjB,IAAI;CAoBlB"}
|
|
@@ -12,253 +12,285 @@ import { interactionArguments, messageArguments } from '../models/Arguments.js';
|
|
|
12
12
|
import { inhibitorValidation } from '../validators/inhibitorValidations.js';
|
|
13
13
|
import { Style } from 'dumfunctions';
|
|
14
14
|
export default class CommandHandler extends Handler {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
15
|
+
constructor(client) {
|
|
16
|
+
super(client);
|
|
17
|
+
}
|
|
18
|
+
loadMessageCommands(options) {
|
|
19
|
+
if (!this.client.options.intents.has(GatewayIntentBits.MessageContent))
|
|
20
|
+
new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
|
|
21
|
+
if (!this.client.options.intents.has(GatewayIntentBits.GuildMessages))
|
|
22
|
+
new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent GuildMessages!`);
|
|
23
|
+
options = z
|
|
24
|
+
.object({
|
|
25
|
+
directory: z.string(),
|
|
26
|
+
prefix: z.string().or(z.array(z.string())),
|
|
27
|
+
allowMention: z.boolean().default(false),
|
|
28
|
+
cooldown: z.number().default(0),
|
|
29
|
+
permissions: z
|
|
30
|
+
.object({
|
|
31
|
+
user: z.array(z.string()).default([]),
|
|
32
|
+
client: z.array(z.string()).default([]),
|
|
33
|
+
dm: z.boolean().default(true),
|
|
34
|
+
})
|
|
35
|
+
.default({}),
|
|
36
|
+
handleEdits: z.boolean().default(false),
|
|
37
|
+
handleDeletes: z.boolean().default(false),
|
|
38
|
+
handleTyping: z.boolean().default(false),
|
|
39
|
+
logging: z.boolean().default(false),
|
|
40
|
+
})
|
|
41
|
+
.parse(options);
|
|
42
|
+
this.client.modules.options.message = options;
|
|
43
|
+
const files = this.readdir(options.directory);
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
46
|
+
this.load(filepath, 'MessageCommand');
|
|
47
|
+
}
|
|
48
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands.`);
|
|
49
|
+
this.emit({
|
|
50
|
+
name: 'messageCreate',
|
|
51
|
+
filetype: 'MessageCommand',
|
|
52
|
+
run: (message) => this.messageCommandRun(message),
|
|
53
|
+
});
|
|
54
|
+
this.emit({
|
|
55
|
+
name: 'messageUpdate',
|
|
56
|
+
filetype: 'MessageCommand',
|
|
57
|
+
run: (message, message2) => this.messageCommandRun(message, message2),
|
|
58
|
+
});
|
|
59
|
+
this.emit({
|
|
60
|
+
name: 'messageDelete',
|
|
61
|
+
filetype: 'MessageCommand',
|
|
62
|
+
run: (message) => this.messageCommandRun(message, 'delete'),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// public reloadMessageCommands() {
|
|
66
|
+
// return reload(this.client, 'message');
|
|
67
|
+
// }
|
|
68
|
+
loadSlashCommands(options) {
|
|
69
|
+
if (!this.client.settings.local)
|
|
70
|
+
new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
|
|
71
|
+
options = z
|
|
72
|
+
.object({
|
|
73
|
+
directory: z.string(),
|
|
74
|
+
cooldown: z.number().default(0),
|
|
75
|
+
permissions: z
|
|
76
|
+
.object({
|
|
77
|
+
user: z.array(z.string()).default([]),
|
|
78
|
+
client: z.array(z.string()).default([]),
|
|
79
|
+
dm: z.boolean().default(true),
|
|
80
|
+
})
|
|
81
|
+
.default({}),
|
|
82
|
+
logging: z.boolean().default(false),
|
|
83
|
+
defer: z
|
|
84
|
+
.object({
|
|
85
|
+
reply: z.boolean().default(false),
|
|
86
|
+
ephemeral: z.boolean().default(false),
|
|
87
|
+
fetchReply: z.boolean().default(false),
|
|
88
|
+
})
|
|
89
|
+
.default({}),
|
|
90
|
+
})
|
|
91
|
+
.parse(options);
|
|
92
|
+
this.client.modules.options.slash = options;
|
|
93
|
+
const files = this.readdir(options.directory);
|
|
94
|
+
for (const file of files) {
|
|
95
|
+
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
96
|
+
this.load(filepath, 'SlashCommand');
|
|
97
|
+
}
|
|
98
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands.`);
|
|
99
|
+
this.emit({
|
|
100
|
+
name: 'interactionCreate',
|
|
101
|
+
filetype: 'SlashCommand',
|
|
102
|
+
run: (interaction) => this.slashCommandRun(interaction),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
loadContextCommands(options) {
|
|
106
|
+
if (!this.client.settings.local)
|
|
107
|
+
new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
|
|
108
|
+
options = z
|
|
109
|
+
.object({
|
|
110
|
+
directory: z.string(),
|
|
111
|
+
cooldown: z.number().default(0),
|
|
112
|
+
permissions: z
|
|
113
|
+
.object({
|
|
114
|
+
user: z.array(z.string()).default([]),
|
|
115
|
+
client: z.array(z.string()).default([]),
|
|
116
|
+
dm: z.boolean().default(true),
|
|
117
|
+
})
|
|
118
|
+
.default({}),
|
|
119
|
+
logging: z.boolean().default(false),
|
|
120
|
+
defer: z
|
|
121
|
+
.object({
|
|
122
|
+
reply: z.boolean().default(false),
|
|
123
|
+
ephemeral: z.boolean().default(false),
|
|
124
|
+
fetchReply: z.boolean().default(false),
|
|
125
|
+
})
|
|
126
|
+
.default({}),
|
|
127
|
+
})
|
|
128
|
+
.parse(options);
|
|
129
|
+
this.client.modules.options.context = options;
|
|
130
|
+
const files = this.readdir(options.directory);
|
|
131
|
+
for (const file of files) {
|
|
132
|
+
const filepath = `${path.resolve(options.directory)}\\${file}`;
|
|
133
|
+
this.load(filepath, 'ContextCommand');
|
|
134
|
+
}
|
|
135
|
+
new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands.`);
|
|
136
|
+
this.emit({
|
|
137
|
+
name: 'interactionCreate',
|
|
138
|
+
filetype: 'ContextCommand',
|
|
139
|
+
run: (interaction) => this.contextCommandRun(interaction),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async messageCommandRun(message, message2) {
|
|
143
|
+
const filetype = 'MessageCommand';
|
|
144
|
+
if (message.author.id === this.client.user?.id && this.client.settings.ignore?.self)
|
|
145
|
+
return;
|
|
146
|
+
else if (message.author.bot && this.client.settings.ignore?.bots)
|
|
147
|
+
return;
|
|
148
|
+
if (message.system && this.client.settings.ignore?.system)
|
|
149
|
+
return;
|
|
150
|
+
message.util = new MessageUtil(this.client, message);
|
|
151
|
+
message.user = await xernerxUser(message, this.client);
|
|
152
|
+
if (typeof message2 === 'object')
|
|
153
|
+
message = message2;
|
|
154
|
+
if (message2 === 'delete' && this.client.modules.options.message?.handleDeletes) {
|
|
155
|
+
if (!this.client.cache.messages.has(message.id))
|
|
156
|
+
return;
|
|
157
|
+
const id = this.client.cache.messages.get(message.id);
|
|
158
|
+
if (!id)
|
|
159
|
+
return;
|
|
160
|
+
(async () => {
|
|
161
|
+
const msg = await message.channel.messages.fetch(id);
|
|
162
|
+
await msg.delete();
|
|
163
|
+
this.client.cache.messages.delete(message.id);
|
|
164
|
+
})();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (message.content && this.client.modules.options.message) {
|
|
168
|
+
const commands = this.client.commands.message;
|
|
169
|
+
const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
|
|
170
|
+
let commandName = null, cmd, commandAlias = null, commandPrefix = null;
|
|
171
|
+
commands.map((command) => {
|
|
172
|
+
let prefix = null;
|
|
173
|
+
if (command.regex && message.content.match(command.regex)) {
|
|
174
|
+
const [match] = message.content.match(command.regex) || [null];
|
|
175
|
+
if (match)
|
|
176
|
+
commandName = command.name;
|
|
177
|
+
}
|
|
178
|
+
const cp = Array.isArray(command.prefix) ? command.prefix : [command.prefix];
|
|
179
|
+
prefixes.map((p) => {
|
|
180
|
+
if (message.content.startsWith(p))
|
|
181
|
+
prefix = p;
|
|
182
|
+
});
|
|
183
|
+
cp.map((p) => {
|
|
184
|
+
if (message.content.startsWith(p))
|
|
185
|
+
prefix = p;
|
|
186
|
+
});
|
|
187
|
+
if (!prefix)
|
|
188
|
+
return;
|
|
189
|
+
if (!commandName)
|
|
190
|
+
commandName =
|
|
191
|
+
message.content
|
|
192
|
+
.replace(prefix, '')
|
|
193
|
+
.split(command.separator || / +/)
|
|
194
|
+
.shift()
|
|
195
|
+
?.trim()
|
|
196
|
+
?.toLowerCase() || '';
|
|
197
|
+
if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
|
|
198
|
+
commandAlias = commandName;
|
|
199
|
+
commandName = command.name;
|
|
200
|
+
}
|
|
201
|
+
commandAlias = commandAlias ? commandAlias : commandName;
|
|
202
|
+
commandPrefix = prefix;
|
|
203
|
+
});
|
|
204
|
+
if (!cmd && this.client.modules.options.message.allowMention) {
|
|
205
|
+
if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
206
|
+
commandName =
|
|
207
|
+
message.content
|
|
208
|
+
.replace(`<@${this.client.user?.id}>`, '')
|
|
209
|
+
.trim()
|
|
210
|
+
.split(/ +/)
|
|
211
|
+
.shift()
|
|
212
|
+
?.toLowerCase() || null;
|
|
213
|
+
commands.map((command) => {
|
|
214
|
+
if (command.aliases?.includes(commandName)) {
|
|
215
|
+
commandName = command.name;
|
|
216
|
+
return (commandAlias = commandName);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
commandPrefix = `<@${this.client.user?.id}>`;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (this.client.commands.message.has(commandName)) {
|
|
223
|
+
if (this.client.modules.options.message?.handleTyping)
|
|
224
|
+
message.channel.sendTyping();
|
|
225
|
+
cmd = this.client.commands.message.get(commandName);
|
|
226
|
+
}
|
|
227
|
+
if (!commandPrefix || !commandName)
|
|
228
|
+
return;
|
|
229
|
+
if (!cmd)
|
|
230
|
+
return await this.client.emit('commandNotFound', message, commandName, filetype);
|
|
231
|
+
if (await inhibitorValidation(message, cmd))
|
|
232
|
+
return;
|
|
233
|
+
message.util.parsed = {
|
|
234
|
+
alias: commandAlias,
|
|
235
|
+
prefix: commandPrefix,
|
|
236
|
+
};
|
|
237
|
+
this.client.emit('commandStart', message, cmd, filetype);
|
|
238
|
+
return await this.exec(cmd, message, await messageArguments(message, cmd, commandPrefix), filetype);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async slashCommandRun(interaction) {
|
|
242
|
+
const filetype = 'SlashCommand';
|
|
243
|
+
interaction.util = new InteractionUtil(this.client, interaction);
|
|
244
|
+
interaction.user = await xernerxUser(interaction, this.client);
|
|
245
|
+
let cmd = null;
|
|
246
|
+
if (this.client.commands.slash.has(interaction.commandName))
|
|
247
|
+
cmd = this.client.commands.slash.get(interaction.commandName);
|
|
248
|
+
if (await inhibitorValidation(interaction, cmd))
|
|
249
|
+
return;
|
|
250
|
+
if (!cmd)
|
|
251
|
+
return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
|
|
252
|
+
new Promise(async (resolve) => {
|
|
253
|
+
if (interaction.isAutocomplete()) {
|
|
254
|
+
const focused = interaction.options.getFocused(true);
|
|
255
|
+
const options = interaction.options;
|
|
256
|
+
await cmd.autocomplete(interaction, focused, options);
|
|
257
|
+
}
|
|
258
|
+
else
|
|
259
|
+
resolve(true);
|
|
260
|
+
})
|
|
261
|
+
.then(async () => {
|
|
262
|
+
this.client.emit('commandStart', interaction, filetype);
|
|
263
|
+
return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
264
|
+
})
|
|
265
|
+
.catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
|
|
266
|
+
}
|
|
267
|
+
async contextCommandRun(interaction) {
|
|
268
|
+
const filetype = 'ContextCommand';
|
|
269
|
+
interaction.util = new InteractionUtil(this.client, interaction);
|
|
270
|
+
interaction.user = await xernerxUser(interaction, this.client);
|
|
271
|
+
let cmd;
|
|
272
|
+
if (this.client.commands.context.has(interaction.commandName))
|
|
273
|
+
cmd = this.client.commands.context.get(interaction.commandName);
|
|
274
|
+
if (await inhibitorValidation(interaction, cmd))
|
|
275
|
+
return;
|
|
276
|
+
if (!cmd)
|
|
277
|
+
return this.client.emit('commandNotFound', interaction, interaction.commandName, filetype);
|
|
278
|
+
this.client.emit('commandStart', interaction, filetype);
|
|
279
|
+
return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
|
|
280
|
+
}
|
|
281
|
+
async exec(cmd, event, args, type) {
|
|
282
|
+
try {
|
|
283
|
+
if (await commandValidation(event, cmd))
|
|
284
|
+
return;
|
|
285
|
+
if (cmd.conditions && (await cmd.conditions(event, args)))
|
|
286
|
+
return;
|
|
287
|
+
await cmd.exec(event, args);
|
|
288
|
+
return await this.client.emit('commandFinish', event, type);
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
|
|
292
|
+
return await this.client.emit('commandError', event, error, cmd, type);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
263
295
|
}
|
|
264
|
-
//# sourceMappingURL=CommandHandler.js.map
|
|
296
|
+
//# sourceMappingURL=CommandHandler.js.map
|