xernerx 4.5.6 → 4.5.7

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.
Files changed (73) hide show
  1. package/dist/build/XernerxContextCommand.d.ts +46 -44
  2. package/dist/build/XernerxContextCommand.js +64 -62
  3. package/dist/build/XernerxEvent.d.ts +16 -14
  4. package/dist/build/XernerxEvent.js +21 -19
  5. package/dist/build/XernerxInhibitor.d.ts +19 -17
  6. package/dist/build/XernerxInhibitor.js +13 -11
  7. package/dist/build/XernerxMessageCommand.d.ts +44 -42
  8. package/dist/build/XernerxMessageCommand.js +58 -56
  9. package/dist/build/XernerxSlashCommand.d.ts +56 -54
  10. package/dist/build/XernerxSlashCommand.js +110 -108
  11. package/dist/client/XernerxClient.d.ts +46 -44
  12. package/dist/client/XernerxClient.js +75 -73
  13. package/dist/client/XernerxShardClient.d.ts +12 -10
  14. package/dist/client/XernerxShardClient.js +50 -48
  15. package/dist/functions/deploy.d.ts +2 -0
  16. package/dist/functions/deploy.js +32 -30
  17. package/dist/functions/load.d.ts +2 -0
  18. package/dist/functions/load.js +29 -27
  19. package/dist/functions/reload.d.ts +2 -0
  20. package/dist/functions/reload.js +36 -34
  21. package/dist/functions/sendWebhook.d.ts +2 -0
  22. package/dist/functions/sendWebhook.js +12 -10
  23. package/dist/functions/setPresence.d.ts +2 -0
  24. package/dist/functions/setPresence.js +19 -17
  25. package/dist/functions/xernerxUser.d.ts +2 -0
  26. package/dist/functions/xernerxUser.js +10 -8
  27. package/dist/handlers/CommandHandler.d.ts +10 -8
  28. package/dist/handlers/CommandHandler.js +241 -239
  29. package/dist/handlers/EventHandler.d.ts +4 -2
  30. package/dist/handlers/EventHandler.js +20 -18
  31. package/dist/handlers/ExtensionHandler.d.ts +4 -2
  32. package/dist/handlers/ExtensionHandler.js +19 -17
  33. package/dist/handlers/Handler.d.ts +9 -7
  34. package/dist/handlers/Handler.js +33 -31
  35. package/dist/handlers/InhibitorHandler.d.ts +4 -2
  36. package/dist/handlers/InhibitorHandler.js +20 -18
  37. package/dist/handlers/WebhookHandler.d.ts +5 -3
  38. package/dist/handlers/WebhookHandler.js +48 -46
  39. package/dist/main.d.ts +28 -26
  40. package/dist/main.js +28 -26
  41. package/dist/models/Arguments.d.ts +4 -2
  42. package/dist/models/Arguments.js +136 -134
  43. package/dist/tools/XernerxError.d.ts +6 -4
  44. package/dist/tools/XernerxError.js +10 -8
  45. package/dist/tools/XernerxLog.d.ts +14 -12
  46. package/dist/tools/XernerxLog.js +77 -80
  47. package/dist/types/extenders.d.ts +13 -11
  48. package/dist/types/extenders.js +2 -0
  49. package/dist/types/interfaces.d.ts +184 -172
  50. package/dist/types/interfaces.d.ts.map +1 -1
  51. package/dist/types/interfaces.js +2 -0
  52. package/dist/types/interfaces.js.map +1 -1
  53. package/dist/types/types.d.ts +173 -171
  54. package/dist/types/types.js +2 -0
  55. package/dist/utils/ClientUtil.d.ts +8 -5
  56. package/dist/utils/ClientUtil.d.ts.map +1 -1
  57. package/dist/utils/ClientUtil.js +45 -26
  58. package/dist/utils/ClientUtil.js.map +1 -1
  59. package/dist/utils/InteractionUtil.d.ts +11 -5
  60. package/dist/utils/InteractionUtil.d.ts.map +1 -1
  61. package/dist/utils/InteractionUtil.js +98 -8
  62. package/dist/utils/InteractionUtil.js.map +1 -1
  63. package/dist/utils/MessageUtil.d.ts +14 -9
  64. package/dist/utils/MessageUtil.d.ts.map +1 -1
  65. package/dist/utils/MessageUtil.js +131 -37
  66. package/dist/utils/MessageUtil.js.map +1 -1
  67. package/dist/utils/Util.d.ts +5 -3
  68. package/dist/utils/Util.js +9 -7
  69. package/dist/validators/commandValidation.d.ts +4 -2
  70. package/dist/validators/commandValidation.js +44 -42
  71. package/dist/validators/inhibitorValidations.d.ts +16 -14
  72. package/dist/validators/inhibitorValidations.js +32 -30
  73. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ /** @format */
2
+
1
3
  import { z } from 'zod';
2
4
  import * as path from 'path';
3
5
  import { GatewayIntentBits } from 'discord.js';
@@ -11,244 +13,244 @@ import { interactionArguments, messageArguments } from '../models/Arguments.js';
11
13
  import { inhibitorValidation } from '../validators/inhibitorValidations.js';
12
14
  import { Style } from 'dumfunctions';
13
15
  export default class CommandHandler extends Handler {
14
- constructor(client) {
15
- super(client);
16
- }
17
- loadMessageCommands(options) {
18
- if (!this.client.options.intents.has(GatewayIntentBits.MessageContent)) new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent MessageContent!`);
19
- if (!this.client.options.intents.has(GatewayIntentBits.GuildMessages)) new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent GuildMessages!`);
20
- options = z
21
- .object({
22
- directory: z.string(),
23
- prefix: z.string().or(z.array(z.string())),
24
- allowMention: z.boolean().default(false),
25
- cooldown: z.number().default(0),
26
- permissions: z
27
- .object({
28
- user: z.array(z.string()).default([]),
29
- client: z.array(z.string()).default([]),
30
- dm: z.boolean().default(true),
31
- })
32
- .default({}),
33
- handleEdits: z.boolean().default(false),
34
- handleDeletes: z.boolean().default(false),
35
- handleTyping: z.boolean().default(false),
36
- logging: z.boolean().default(false),
37
- })
38
- .parse(options);
39
- this.client.modules.options.message = options;
40
- const files = this.readdir(options.directory);
41
- for (const file of files) {
42
- const filePath = `${path.resolve(options.directory)}\\${file}`;
43
- this.load(filePath, 'MessageCommand');
44
- }
45
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands.`);
46
- this.emit({
47
- name: 'messageCreate',
48
- fileType: 'MessageCommand',
49
- run: (message) => this.messageCommandRun(message),
50
- });
51
- this.emit({
52
- name: 'messageUpdate',
53
- fileType: 'MessageCommand',
54
- run: (message, message2) => this.messageCommandRun(message, message2),
55
- });
56
- this.emit({
57
- name: 'messageDelete',
58
- fileType: 'MessageCommand',
59
- run: (message) => this.messageCommandRun(message, 'delete'),
60
- });
61
- }
62
- // public reloadMessageCommands() {
63
- // return reload(this.client, 'message');
64
- // }
65
- loadSlashCommands(options) {
66
- if (!this.client.settings.local) new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
67
- options = z
68
- .object({
69
- directory: z.string(),
70
- cooldown: z.number().default(0),
71
- permissions: z
72
- .object({
73
- user: z.array(z.string()).default([]),
74
- client: z.array(z.string()).default([]),
75
- dm: z.boolean().default(true),
76
- })
77
- .default({}),
78
- logging: z.boolean().default(false),
79
- defer: z
80
- .object({
81
- reply: z.boolean().default(false),
82
- ephemeral: z.boolean().default(false),
83
- fetchReply: z.boolean().default(false),
84
- })
85
- .default({}),
86
- })
87
- .parse(options);
88
- this.client.modules.options.slash = options;
89
- const files = this.readdir(options.directory);
90
- for (const file of files) {
91
- const filePath = `${path.resolve(options.directory)}\\${file}`;
92
- this.load(filePath, 'SlashCommand');
93
- }
94
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands.`);
95
- this.emit({
96
- name: 'interactionCreate',
97
- fileType: 'SlashCommand',
98
- run: (interaction) => this.slashCommandRun(interaction),
99
- });
100
- }
101
- loadContextCommands(options) {
102
- if (!this.client.settings.local) new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
103
- options = z
104
- .object({
105
- directory: z.string(),
106
- cooldown: z.number().default(0),
107
- permissions: z
108
- .object({
109
- user: z.array(z.string()).default([]),
110
- client: z.array(z.string()).default([]),
111
- dm: z.boolean().default(true),
112
- })
113
- .default({}),
114
- logging: z.boolean().default(false),
115
- defer: z
116
- .object({
117
- reply: z.boolean().default(false),
118
- ephemeral: z.boolean().default(false),
119
- fetchReply: z.boolean().default(false),
120
- })
121
- .default({}),
122
- })
123
- .parse(options);
124
- this.client.modules.options.context = options;
125
- const files = this.readdir(options.directory);
126
- for (const file of files) {
127
- const filePath = `${path.resolve(options.directory)}\\${file}`;
128
- this.load(filePath, 'ContextCommand');
129
- }
130
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands.`);
131
- this.emit({
132
- name: 'interactionCreate',
133
- fileType: 'ContextCommand',
134
- run: (interaction) => this.contextCommandRun(interaction),
135
- });
136
- }
137
- async messageCommandRun(message, message2) {
138
- const filetype = 'MessageCommand';
139
- if (message.author.bot) return;
140
- message.util = new MessageUtil(this.client, message);
141
- message.user = await xernerxUser(message, this.client);
142
- if (typeof message2 === 'object') message = message2;
143
- if (message2 === 'delete') {
144
- if (!this.client.cache.messages.has(message.id)) return;
145
- const id = this.client.cache.messages.get(message.id);
146
- if (!id) return;
147
- (async () => {
148
- const msg = await message.channel.messages.fetch(id);
149
- await msg.delete();
150
- this.client.cache.messages.delete(message.id);
151
- })();
152
- return;
153
- }
154
- if (message.content && this.client.modules.options.message) {
155
- const commands = this.client.commands.message;
156
- const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
157
- let commandName = null,
158
- cmd,
159
- commandAlias = null,
160
- commandPrefix = null;
161
- commands.map((command) => {
162
- let prefix = null;
163
- if (command.regex && message.content.match(command.regex)) {
164
- const [match] = message.content.match(command.regex) || [null];
165
- if (match) commandName = command.name;
166
- }
167
- const cp = Array.isArray(command.prefix) ? command.prefix : [command.prefix];
168
- prefixes.map((p) => {
169
- if (message.content.startsWith(p)) prefix = p;
170
- });
171
- cp.map((p) => {
172
- if (message.content.startsWith(p)) prefix = p;
173
- });
174
- if (!prefix) return;
175
- if (!commandName)
176
- commandName =
177
- message.content
178
- .replace(prefix, '')
179
- .split(command.separator || / +/)
180
- .shift()
181
- ?.trim()
182
- ?.toLowerCase() || '';
183
- if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
184
- commandAlias = commandName;
185
- commandName = command.name;
186
- }
187
- commandAlias = commandAlias ? commandAlias : commandName;
188
- commandPrefix = prefix;
189
- });
190
- if (!cmd && this.client.modules.options.message.allowMention) {
191
- if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
192
- commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase() || null;
193
- commandPrefix = `<@${this.client.user?.id}>`;
194
- }
195
- }
196
- if (this.client.commands.message.has(commandName)) {
197
- if (this.client.modules.options.message?.handleTyping) message.channel.sendTyping();
198
- cmd = this.client.commands.message.get(commandName);
199
- }
200
- if (!cmd) return this.client.emit('commandNotFound', message, filetype);
201
- if (await inhibitorValidation(message, cmd)) return;
202
- message.util.parsed = {
203
- alias: commandAlias,
204
- prefix: commandPrefix,
205
- };
206
- this.client.emit('commandStart', message, cmd, filetype);
207
- return await this.exec(cmd, message, await messageArguments(message, cmd, commandPrefix), filetype);
208
- }
209
- }
210
- async slashCommandRun(interaction) {
211
- const filetype = 'SlashCommand';
212
- interaction.util = new InteractionUtil(this.client, interaction);
213
- interaction.user = await xernerxUser(interaction, this.client);
214
- let cmd = null;
215
- if (this.client.commands.slash.has(interaction.commandName)) cmd = this.client.commands.slash.get(interaction.commandName);
216
- if (await inhibitorValidation(interaction, cmd)) return;
217
- if (!cmd) return this.client.emit('commandNotFound', interaction);
218
- new Promise(async (resolve) => {
219
- if (interaction.isAutocomplete()) {
220
- const focused = interaction.options.getFocused(true);
221
- const options = interaction.options;
222
- await cmd.autocomplete(interaction, focused, options);
223
- } else resolve(true);
224
- })
225
- .then(async () => {
226
- this.client.emit('commandStart', interaction, filetype);
227
- return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
228
- })
229
- .catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
230
- }
231
- async contextCommandRun(interaction) {
232
- const filetype = 'ContextCommand';
233
- interaction.util = new InteractionUtil(this.client, interaction);
234
- interaction.user = await xernerxUser(interaction, this.client);
235
- let cmd;
236
- if (this.client.commands.context.has(interaction.commandName)) cmd = this.client.commands.context.get(interaction.commandName);
237
- if (await inhibitorValidation(interaction, cmd)) return;
238
- if (!cmd) return this.client.emit('commandNotFound', interaction, filetype);
239
- this.client.emit('commandStart', interaction, filetype);
240
- return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
241
- }
242
- async exec(cmd, event, args, type) {
243
- try {
244
- if (await commandValidation(event, cmd)) return;
245
- if (cmd.conditions && (await cmd.conditions(event, args))) return;
246
- await cmd.exec(event, args);
247
- return await this.client.emit('commandFinish', event, type);
248
- } catch (error) {
249
- new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
250
- return await this.client.emit('commandError', event, error, cmd, type);
251
- }
252
- }
16
+ constructor(client) {
17
+ super(client);
18
+ }
19
+ loadMessageCommands(options) {
20
+ if (!this.client.options.intents.has(GatewayIntentBits.MessageContent)) 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)) new XernerxLog(this.client).warn(`Message commands might not work as you're missing the intent GuildMessages!`);
22
+ options = z
23
+ .object({
24
+ directory: z.string(),
25
+ prefix: z.string().or(z.array(z.string())),
26
+ allowMention: z.boolean().default(false),
27
+ cooldown: z.number().default(0),
28
+ permissions: z
29
+ .object({
30
+ user: z.array(z.string()).default([]),
31
+ client: z.array(z.string()).default([]),
32
+ dm: z.boolean().default(true),
33
+ })
34
+ .default({}),
35
+ handleEdits: z.boolean().default(false),
36
+ handleDeletes: z.boolean().default(false),
37
+ handleTyping: z.boolean().default(false),
38
+ logging: z.boolean().default(false),
39
+ })
40
+ .parse(options);
41
+ this.client.modules.options.message = options;
42
+ const files = this.readdir(options.directory);
43
+ for (const file of files) {
44
+ const filePath = `${path.resolve(options.directory)}\\${file}`;
45
+ this.load(filePath, 'MessageCommand');
46
+ }
47
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Message Commands.`);
48
+ this.emit({
49
+ name: 'messageCreate',
50
+ fileType: 'MessageCommand',
51
+ run: (message) => this.messageCommandRun(message),
52
+ });
53
+ this.emit({
54
+ name: 'messageUpdate',
55
+ fileType: 'MessageCommand',
56
+ run: (message, message2) => this.messageCommandRun(message, message2),
57
+ });
58
+ this.emit({
59
+ name: 'messageDelete',
60
+ fileType: 'MessageCommand',
61
+ run: (message) => this.messageCommandRun(message, 'delete'),
62
+ });
63
+ }
64
+ // public reloadMessageCommands() {
65
+ // return reload(this.client, 'message');
66
+ // }
67
+ loadSlashCommands(options) {
68
+ if (!this.client.settings.local) new XernerxLog(this.client).warn(`Slash commands might not work as you haven't specified a local guild ID.`);
69
+ options = z
70
+ .object({
71
+ directory: z.string(),
72
+ cooldown: z.number().default(0),
73
+ permissions: z
74
+ .object({
75
+ user: z.array(z.string()).default([]),
76
+ client: z.array(z.string()).default([]),
77
+ dm: z.boolean().default(true),
78
+ })
79
+ .default({}),
80
+ logging: z.boolean().default(false),
81
+ defer: z
82
+ .object({
83
+ reply: z.boolean().default(false),
84
+ ephemeral: z.boolean().default(false),
85
+ fetchReply: z.boolean().default(false),
86
+ })
87
+ .default({}),
88
+ })
89
+ .parse(options);
90
+ this.client.modules.options.slash = options;
91
+ const files = this.readdir(options.directory);
92
+ for (const file of files) {
93
+ const filePath = `${path.resolve(options.directory)}\\${file}`;
94
+ this.load(filePath, 'SlashCommand');
95
+ }
96
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Slash Commands.`);
97
+ this.emit({
98
+ name: 'interactionCreate',
99
+ fileType: 'SlashCommand',
100
+ run: (interaction) => this.slashCommandRun(interaction),
101
+ });
102
+ }
103
+ loadContextCommands(options) {
104
+ if (!this.client.settings.local) new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
105
+ options = z
106
+ .object({
107
+ directory: z.string(),
108
+ cooldown: z.number().default(0),
109
+ permissions: z
110
+ .object({
111
+ user: z.array(z.string()).default([]),
112
+ client: z.array(z.string()).default([]),
113
+ dm: z.boolean().default(true),
114
+ })
115
+ .default({}),
116
+ logging: z.boolean().default(false),
117
+ defer: z
118
+ .object({
119
+ reply: z.boolean().default(false),
120
+ ephemeral: z.boolean().default(false),
121
+ fetchReply: z.boolean().default(false),
122
+ })
123
+ .default({}),
124
+ })
125
+ .parse(options);
126
+ this.client.modules.options.context = options;
127
+ const files = this.readdir(options.directory);
128
+ for (const file of files) {
129
+ const filePath = `${path.resolve(options.directory)}\\${file}`;
130
+ this.load(filePath, 'ContextCommand');
131
+ }
132
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(files.length), { color: Style.TextColor.Cyan })} Context Commands.`);
133
+ this.emit({
134
+ name: 'interactionCreate',
135
+ fileType: 'ContextCommand',
136
+ run: (interaction) => this.contextCommandRun(interaction),
137
+ });
138
+ }
139
+ async messageCommandRun(message, message2) {
140
+ const filetype = 'MessageCommand';
141
+ if (message.author.bot) return;
142
+ message.util = new MessageUtil(this.client, message);
143
+ message.user = await xernerxUser(message, this.client);
144
+ if (typeof message2 === 'object') message = message2;
145
+ if (message2 === 'delete') {
146
+ if (!this.client.cache.messages.has(message.id)) return;
147
+ const id = this.client.cache.messages.get(message.id);
148
+ if (!id) return;
149
+ (async () => {
150
+ const msg = await message.channel.messages.fetch(id);
151
+ await msg.delete();
152
+ this.client.cache.messages.delete(message.id);
153
+ })();
154
+ return;
155
+ }
156
+ if (message.content && this.client.modules.options.message) {
157
+ const commands = this.client.commands.message;
158
+ const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
159
+ let commandName = null,
160
+ cmd,
161
+ commandAlias = null,
162
+ commandPrefix = null;
163
+ commands.map((command) => {
164
+ let prefix = null;
165
+ if (command.regex && message.content.match(command.regex)) {
166
+ const [match] = message.content.match(command.regex) || [null];
167
+ if (match) commandName = command.name;
168
+ }
169
+ const cp = Array.isArray(command.prefix) ? command.prefix : [command.prefix];
170
+ prefixes.map((p) => {
171
+ if (message.content.startsWith(p)) prefix = p;
172
+ });
173
+ cp.map((p) => {
174
+ if (message.content.startsWith(p)) prefix = p;
175
+ });
176
+ if (!prefix) return;
177
+ if (!commandName)
178
+ commandName =
179
+ message.content
180
+ .replace(prefix, '')
181
+ .split(command.separator || / +/)
182
+ .shift()
183
+ ?.trim()
184
+ ?.toLowerCase() || '';
185
+ if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
186
+ commandAlias = commandName;
187
+ commandName = command.name;
188
+ }
189
+ commandAlias = commandAlias ? commandAlias : commandName;
190
+ commandPrefix = prefix;
191
+ });
192
+ if (!cmd && this.client.modules.options.message.allowMention) {
193
+ if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
194
+ commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase() || null;
195
+ commandPrefix = `<@${this.client.user?.id}>`;
196
+ }
197
+ }
198
+ if (this.client.commands.message.has(commandName)) {
199
+ if (this.client.modules.options.message?.handleTyping) message.channel.sendTyping();
200
+ cmd = this.client.commands.message.get(commandName);
201
+ }
202
+ if (!cmd) return this.client.emit('commandNotFound', message, filetype);
203
+ if (await inhibitorValidation(message, cmd)) return;
204
+ message.util.parsed = {
205
+ alias: commandAlias,
206
+ prefix: commandPrefix,
207
+ };
208
+ this.client.emit('commandStart', message, cmd, filetype);
209
+ return await this.exec(cmd, message, await messageArguments(message, cmd, commandPrefix), filetype);
210
+ }
211
+ }
212
+ async slashCommandRun(interaction) {
213
+ const filetype = 'SlashCommand';
214
+ interaction.util = new InteractionUtil(this.client, interaction);
215
+ interaction.user = await xernerxUser(interaction, this.client);
216
+ let cmd = null;
217
+ if (this.client.commands.slash.has(interaction.commandName)) cmd = this.client.commands.slash.get(interaction.commandName);
218
+ if (await inhibitorValidation(interaction, cmd)) return;
219
+ if (!cmd) return this.client.emit('commandNotFound', interaction);
220
+ new Promise(async (resolve) => {
221
+ if (interaction.isAutocomplete()) {
222
+ const focused = interaction.options.getFocused(true);
223
+ const options = interaction.options;
224
+ await cmd.autocomplete(interaction, focused, options);
225
+ } else resolve(true);
226
+ })
227
+ .then(async () => {
228
+ this.client.emit('commandStart', interaction, filetype);
229
+ return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
230
+ })
231
+ .catch((error) => this.client.emit('commandError', interaction, error, cmd, filetype));
232
+ }
233
+ async contextCommandRun(interaction) {
234
+ const filetype = 'ContextCommand';
235
+ interaction.util = new InteractionUtil(this.client, interaction);
236
+ interaction.user = await xernerxUser(interaction, this.client);
237
+ let cmd;
238
+ if (this.client.commands.context.has(interaction.commandName)) cmd = this.client.commands.context.get(interaction.commandName);
239
+ if (await inhibitorValidation(interaction, cmd)) return;
240
+ if (!cmd) return this.client.emit('commandNotFound', interaction, filetype);
241
+ this.client.emit('commandStart', interaction, filetype);
242
+ return await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
243
+ }
244
+ async exec(cmd, event, args, type) {
245
+ try {
246
+ if (await commandValidation(event, cmd)) return;
247
+ if (cmd.conditions && (await cmd.conditions(event, args))) return;
248
+ await cmd.exec(event, args);
249
+ return await this.client.emit('commandFinish', event, type);
250
+ } catch (error) {
251
+ new XernerxLog(this.client).error(`An error occurred executing ${Style.log(cmd.name, { color: Style.TextColor.Blue })}`, error);
252
+ return await this.client.emit('commandError', event, error, cmd, type);
253
+ }
254
+ }
253
255
  }
254
256
  //# sourceMappingURL=CommandHandler.js.map
@@ -1,8 +1,10 @@
1
+ /** @format */
2
+
1
3
  import XernerxClient from '../client/XernerxClient.js';
2
4
  import { EventHandlerOptions } from '../types/interfaces.js';
3
5
  import Handler from './Handler.js';
4
6
  export default class EventHandler extends Handler {
5
- constructor(client: XernerxClient);
6
- loadEvents(options: EventHandlerOptions): Promise<void>;
7
+ constructor(client: XernerxClient);
8
+ loadEvents(options: EventHandlerOptions): Promise<void>;
7
9
  }
8
10
  //# sourceMappingURL=EventHandler.d.ts.map
@@ -1,26 +1,28 @@
1
+ /** @format */
2
+
1
3
  import { z } from 'zod';
2
4
  import * as path from 'path';
3
5
  import Handler from './Handler.js';
4
6
  import XernerxLog from '../tools/XernerxLog.js';
5
7
  import { Style } from 'dumfunctions';
6
8
  export default class EventHandler extends Handler {
7
- constructor(client) {
8
- super(client);
9
- }
10
- async loadEvents(options) {
11
- options = z
12
- .object({
13
- directory: z.string(),
14
- })
15
- .parse(options);
16
- this.client.modules.options.events = options;
17
- const files = this.readdir(options.directory);
18
- for (const file of files) {
19
- const filePath = `${path.resolve(options.directory)}\\${file}`;
20
- const data = await this.load(filePath, 'Event');
21
- this.emit(data);
22
- }
23
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events.`);
24
- }
9
+ constructor(client) {
10
+ super(client);
11
+ }
12
+ async loadEvents(options) {
13
+ options = z
14
+ .object({
15
+ directory: z.string(),
16
+ })
17
+ .parse(options);
18
+ this.client.modules.options.events = options;
19
+ const files = this.readdir(options.directory);
20
+ for (const file of files) {
21
+ const filePath = `${path.resolve(options.directory)}\\${file}`;
22
+ const data = await this.load(filePath, 'Event');
23
+ this.emit(data);
24
+ }
25
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(this.client.events.size), { color: Style.TextColor.Cyan })} Events.`);
26
+ }
25
27
  }
26
28
  //# sourceMappingURL=EventHandler.js.map
@@ -1,8 +1,10 @@
1
+ /** @format */
2
+
1
3
  import XernerxExtensionBuilder from 'xernerx-extension-builder';
2
4
  import XernerxClient from '../client/XernerxClient.js';
3
5
  import Handler from './Handler.js';
4
6
  export default class ExtensionHandler extends Handler {
5
- constructor(client: XernerxClient);
6
- loadExtensions(...extensions: Array<XernerxExtensionBuilder>): void;
7
+ constructor(client: XernerxClient);
8
+ loadExtensions(...extensions: Array<XernerxExtensionBuilder>): void;
7
9
  }
8
10
  //# sourceMappingURL=ExtensionHandler.d.ts.map
@@ -1,23 +1,25 @@
1
+ /** @format */
2
+
1
3
  import Handler from './Handler.js';
2
4
  import XernerxLog from '../tools/XernerxLog.js';
3
5
  import { Style } from 'dumfunctions';
4
6
  export default class ExtensionHandler extends Handler {
5
- constructor(client) {
6
- super(client);
7
- }
8
- loadExtensions(...extensions) {
9
- const active = extensions.map((extension) => {
10
- try {
11
- if (extension.main) extension.main(this.client);
12
- if (extension.defer) {
13
- this.client.on('ready', (client) => extension.defer(client));
14
- }
15
- return extension.name;
16
- } catch (error) {
17
- return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.Blue })}`, error);
18
- }
19
- });
20
- new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active.filter((e) => e).join(', ')}`);
21
- }
7
+ constructor(client) {
8
+ super(client);
9
+ }
10
+ loadExtensions(...extensions) {
11
+ const active = extensions.map((extension) => {
12
+ try {
13
+ if (extension.main) extension.main(this.client);
14
+ if (extension.defer) {
15
+ this.client.on('ready', (client) => extension.defer(client));
16
+ }
17
+ return extension.name;
18
+ } catch (error) {
19
+ return new XernerxLog(this.client).error(`An error occurred while loading ${Style.log(extension.name, { color: Style.TextColor.Blue })}`, error);
20
+ }
21
+ });
22
+ new XernerxLog(this.client).info(`Loaded ${Style.log(String(extensions.length), { color: Style.TextColor.Cyan })} Extensions: ${active.filter((e) => e).join(', ')}`);
23
+ }
22
24
  }
23
25
  //# sourceMappingURL=ExtensionHandler.js.map
@@ -1,15 +1,17 @@
1
+ /** @format */
2
+
1
3
  import XernerxClient from '../client/XernerxClient.js';
2
4
  import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
3
5
  import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
4
6
  import XernerxContextCommand from '../build/XernerxContextCommand.js';
5
7
  import { FileType } from '../types/types.js';
6
8
  export default class Handler {
7
- readonly client: XernerxClient<unknown>;
8
- readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
9
- readonly readyTimestamp: number;
10
- constructor(client: XernerxClient);
11
- readdir(dir: string): string[];
12
- load(filePath: string, type: FileType): Promise<any>;
13
- emit<T extends Record<string, string | boolean | Function | void>>(event: T): Promise<void>;
9
+ readonly client: XernerxClient<unknown>;
10
+ readonly files: Array<MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand>;
11
+ readonly readyTimestamp: number;
12
+ constructor(client: XernerxClient);
13
+ readdir(dir: string): string[];
14
+ load(filePath: string, type: FileType): Promise<any>;
15
+ emit<T extends Record<string, string | boolean | Function | void>>(event: T): Promise<void>;
14
16
  }
15
17
  //# sourceMappingURL=Handler.d.ts.map