xernerx 4.1.0 → 4.2.1

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 (112) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/build/ContextCommandBuilder.d.ts +68 -0
  3. package/dist/cjs/build/ContextCommandBuilder.js +97 -0
  4. package/dist/cjs/build/EventBuilder.d.ts +21 -0
  5. package/dist/cjs/build/EventBuilder.js +44 -0
  6. package/dist/cjs/build/InhibitorBuilder.d.ts +19 -0
  7. package/dist/cjs/build/InhibitorBuilder.js +37 -0
  8. package/dist/cjs/build/MessageCommandBuilder.d.ts +59 -0
  9. package/dist/cjs/build/MessageCommandBuilder.js +100 -0
  10. package/dist/cjs/build/SlashCommandBuilder.d.ts +64 -0
  11. package/dist/cjs/build/SlashCommandBuilder.js +168 -0
  12. package/dist/cjs/client/XernerxClient.d.ts +28 -0
  13. package/dist/cjs/client/XernerxClient.js +116 -0
  14. package/dist/cjs/handlers/CommandHandler.d.ts +27 -0
  15. package/dist/cjs/handlers/CommandHandler.js +45 -0
  16. package/dist/cjs/handlers/EventHandler.d.ts +13 -0
  17. package/dist/cjs/handlers/EventHandler.js +19 -0
  18. package/dist/cjs/handlers/Handler.d.ts +57 -0
  19. package/dist/cjs/handlers/Handler.js +308 -0
  20. package/dist/cjs/handlers/InhibitorHandler.d.ts +18 -0
  21. package/dist/cjs/handlers/InhibitorHandler.js +24 -0
  22. package/dist/cjs/main.d.ts +44 -0
  23. package/dist/cjs/main.js +112 -0
  24. package/dist/cjs/models/CommandArguments.d.ts +17 -0
  25. package/dist/cjs/models/CommandArguments.js +106 -0
  26. package/dist/cjs/models/Events.d.ts +24 -0
  27. package/dist/cjs/models/Events.js +307 -0
  28. package/dist/cjs/models/Extensions.d.ts +7 -0
  29. package/dist/cjs/models/Extensions.js +26 -0
  30. package/dist/cjs/tools/XernerxError.d.ts +5 -0
  31. package/dist/cjs/tools/XernerxError.js +11 -0
  32. package/dist/cjs/tools/package.d.ts +49 -0
  33. package/dist/cjs/tools/package.js +50 -0
  34. package/dist/cjs/types/enums.d.ts +44 -0
  35. package/dist/cjs/types/enums.js +38 -0
  36. package/dist/cjs/types/interfaces.d.ts +25 -0
  37. package/dist/cjs/types/interfaces.js +2 -0
  38. package/dist/cjs/types/options.d.ts +241 -0
  39. package/dist/cjs/types/options.js +2 -0
  40. package/dist/cjs/types/types.d.ts +61 -0
  41. package/dist/cjs/types/types.js +2 -0
  42. package/dist/cjs/utils/ClientUtil.d.ts +25 -0
  43. package/dist/cjs/utils/ClientUtil.js +211 -0
  44. package/dist/cjs/utils/CommandUtil.d.ts +58 -0
  45. package/dist/cjs/utils/CommandUtil.js +247 -0
  46. package/dist/cjs/validators/CommandValidations.d.ts +12 -0
  47. package/dist/cjs/validators/CommandValidations.js +169 -0
  48. package/dist/cjs/validators/InhibitorValidations.d.ts +11 -0
  49. package/dist/cjs/validators/InhibitorValidations.js +40 -0
  50. package/dist/client/XernerxClient.d.ts +5 -4
  51. package/dist/client/XernerxClient.js +2 -10
  52. package/dist/functions/deploy.js +20 -20
  53. package/dist/handlers/CommandHandler.js +28 -13
  54. package/dist/main.d.ts +1 -1
  55. package/dist/main.js +1 -1
  56. package/dist/mjs/build/ContextCommandBuilder.d.ts +68 -0
  57. package/dist/mjs/build/ContextCommandBuilder.js +88 -0
  58. package/dist/mjs/build/EventBuilder.d.ts +21 -0
  59. package/dist/mjs/build/EventBuilder.js +34 -0
  60. package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
  61. package/dist/mjs/build/InhibitorBuilder.js +27 -0
  62. package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
  63. package/dist/mjs/build/MessageCommandBuilder.js +90 -0
  64. package/dist/mjs/build/SlashCommandBuilder.d.ts +64 -0
  65. package/dist/mjs/build/SlashCommandBuilder.js +121 -0
  66. package/dist/mjs/client/XernerxClient.d.ts +28 -0
  67. package/dist/mjs/client/XernerxClient.js +108 -0
  68. package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
  69. package/dist/mjs/handlers/CommandHandler.js +42 -0
  70. package/dist/mjs/handlers/EventHandler.d.ts +13 -0
  71. package/dist/mjs/handlers/EventHandler.js +16 -0
  72. package/dist/mjs/handlers/Handler.d.ts +57 -0
  73. package/dist/mjs/handlers/Handler.js +260 -0
  74. package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
  75. package/dist/mjs/handlers/InhibitorHandler.js +21 -0
  76. package/dist/mjs/main.d.ts +44 -0
  77. package/dist/mjs/main.js +52 -0
  78. package/dist/mjs/models/CommandArguments.d.ts +17 -0
  79. package/dist/mjs/models/CommandArguments.js +101 -0
  80. package/dist/mjs/models/Events.d.ts +24 -0
  81. package/dist/mjs/models/Events.js +295 -0
  82. package/dist/mjs/models/Extensions.d.ts +7 -0
  83. package/dist/mjs/models/Extensions.js +23 -0
  84. package/dist/mjs/tools/XernerxError.d.ts +5 -0
  85. package/dist/mjs/tools/XernerxError.js +8 -0
  86. package/dist/mjs/tools/package.d.ts +49 -0
  87. package/dist/mjs/tools/package.js +48 -0
  88. package/dist/mjs/types/enums.d.ts +44 -0
  89. package/dist/mjs/types/enums.js +35 -0
  90. package/dist/mjs/types/interfaces.d.ts +25 -0
  91. package/dist/mjs/types/interfaces.js +1 -0
  92. package/dist/mjs/types/options.d.ts +241 -0
  93. package/dist/mjs/types/options.js +1 -0
  94. package/dist/mjs/types/types.d.ts +61 -0
  95. package/dist/mjs/types/types.js +1 -0
  96. package/dist/mjs/utils/ClientUtil.d.ts +25 -0
  97. package/dist/mjs/utils/ClientUtil.js +202 -0
  98. package/dist/mjs/utils/CommandUtil.d.ts +58 -0
  99. package/dist/mjs/utils/CommandUtil.js +232 -0
  100. package/dist/mjs/validators/CommandValidations.d.ts +12 -0
  101. package/dist/mjs/validators/CommandValidations.js +166 -0
  102. package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
  103. package/dist/mjs/validators/InhibitorValidations.js +36 -0
  104. package/dist/tools/XernerxLog.d.ts +1 -0
  105. package/dist/tools/XernerxLog.js +26 -8
  106. package/dist/types/extenders.d.ts +11 -6
  107. package/dist/types/interfaces.d.ts +23 -19
  108. package/dist/utils/ClientUtil.d.ts +2 -1
  109. package/dist/utils/ClientUtil.js +10 -1
  110. package/dist/utils/MessageUtil.d.ts +4 -1
  111. package/dist/utils/MessageUtil.js +4 -2
  112. package/package.json +1 -1
@@ -63,6 +63,7 @@ export default class CommandHandler extends Handler {
63
63
  // return reload(this.client, 'message');
64
64
  // }
65
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.`);
66
67
  options = z
67
68
  .object({
68
69
  directory: z.string(),
@@ -99,6 +100,7 @@ export default class CommandHandler extends Handler {
99
100
  });
100
101
  }
101
102
  loadContextCommands(options) {
103
+ if (!this.client.settings.local) new XernerxLog(this.client).warn(`Context commands might not work as you haven't specified a local guild ID.`);
102
104
  options = z
103
105
  .object({
104
106
  directory: z.string(),
@@ -135,6 +137,7 @@ export default class CommandHandler extends Handler {
135
137
  });
136
138
  }
137
139
  async messageCommandRun(message, message2) {
140
+ const filetype = 'MessageCommand';
138
141
  if (message.author.bot) return;
139
142
  message.util = new MessageUtil(this.client, message);
140
143
  message.user = await xernerxUser(message, this.client);
@@ -153,9 +156,10 @@ export default class CommandHandler extends Handler {
153
156
  if (message.content && this.client.modules.options.message) {
154
157
  const commands = this.client.commands.message;
155
158
  const prefixes = Array.isArray(this.client.modules.options.message.prefix) ? this.client.modules.options.message.prefix : [this.client.modules.options.message.prefix];
156
- let commandName,
159
+ let commandName = null,
157
160
  cmd,
158
- alias = null;
161
+ commandAlias = null,
162
+ commandPrefix = null;
159
163
  commands.map((command) => {
160
164
  let prefix = null;
161
165
  if (command.regex && message.content.match(command.regex)) {
@@ -179,24 +183,30 @@ export default class CommandHandler extends Handler {
179
183
  ?.trim()
180
184
  ?.toLowerCase() || '';
181
185
  if (!this.client.commands.message.has(commandName) && command.aliases?.includes(commandName)) {
182
- alias = commandName;
186
+ commandAlias = commandName;
183
187
  commandName = command.name;
184
188
  }
189
+ commandAlias = commandAlias ? commandAlias : commandName;
190
+ commandPrefix = prefix;
185
191
  });
186
192
  if (!cmd && this.client.modules.options.message.allowMention) {
187
193
  if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
188
- commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase();
194
+ commandName = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift()?.toLowerCase() || null;
189
195
  }
190
196
  }
191
- if (!commandName) commandName = '';
192
197
  if (this.client.commands.message.has(commandName)) cmd = this.client.commands.message.get(commandName);
193
198
  if (await inhibitorValidation(message, cmd)) return;
194
- if (!cmd) return this.client.emit('commandNotFound');
195
- message.util.alias = alias === commandName ? null : alias;
196
- this.exec(cmd, message, await messageArguments(message, cmd), 'MessageCommand');
199
+ if (!cmd) return this.client.emit('commandNotFound', message, filetype);
200
+ message.util.parsed = {
201
+ alias: commandAlias,
202
+ prefix: commandPrefix,
203
+ };
204
+ this.client.emit('commandStart', message, filetype);
205
+ this.exec(cmd, message, await messageArguments(message, cmd), filetype);
197
206
  }
198
207
  }
199
208
  async slashCommandRun(interaction) {
209
+ const filetype = 'SlashCommand';
200
210
  interaction.util = new InteractionUtil(this.client, interaction);
201
211
  interaction.user = await xernerxUser(interaction, this.client);
202
212
  let cmd = null;
@@ -210,24 +220,29 @@ export default class CommandHandler extends Handler {
210
220
  await cmd.autocomplete(interaction, focused, options);
211
221
  } else resolve(true);
212
222
  })
213
- .then(async () => await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), 'SlashCommand'))
214
- .catch((error) => this.client.emit('commandError', interaction, error, cmd.filetype));
223
+ .then(async () => {
224
+ this.client.emit('commandStart', interaction, filetype);
225
+ await this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
226
+ })
227
+ .catch((error) => this.client.emit('commandError', interaction, error, filetype));
215
228
  }
216
229
  async contextCommandRun(interaction) {
230
+ const filetype = 'ContextCommand';
217
231
  interaction.util = new InteractionUtil(this.client, interaction);
218
232
  interaction.user = await xernerxUser(interaction, this.client);
219
233
  let cmd;
220
234
  if (this.client.commands.context.has(interaction.commandName)) cmd = this.client.commands.context.get(interaction.commandName);
221
235
  if (await inhibitorValidation(interaction, cmd)) return;
222
- if (!cmd) return this.client.emit('commandNotFound', interaction);
223
- this.exec(cmd, interaction, await interactionArguments(interaction, cmd), 'ContextCommand');
236
+ if (!cmd) return this.client.emit('commandNotFound', interaction, filetype);
237
+ this.client.emit('commandStart', interaction, filetype);
238
+ this.exec(cmd, interaction, await interactionArguments(interaction, cmd), filetype);
224
239
  }
225
240
  async exec(cmd, event, args, type) {
226
241
  try {
227
242
  if (await commandValidation(event, cmd)) return;
228
243
  if (cmd.conditions && (await cmd.conditions(event, args))) return;
229
244
  cmd.exec(event, args);
230
- this.client.emit('commandExecute', event, type);
245
+ this.client.emit('commandFinish', event, type);
231
246
  } catch (error) {
232
247
  new XernerxLog(this.client).error(`An error occurred executing ${cmd.name}`, error);
233
248
  this.client.emit('commandError', event, error, type);
package/dist/main.d.ts CHANGED
@@ -10,5 +10,5 @@ export * from 'discord.js';
10
10
  export * from 'dumfunctions';
11
11
  import ExtensionBuilder from 'xernerx-extension-builder';
12
12
  import Discord from 'discord.js';
13
- declare const version = '4.1.0';
13
+ declare const version = '4.2.1';
14
14
  export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
package/dist/main.js CHANGED
@@ -10,5 +10,5 @@ export * from 'discord.js';
10
10
  export * from 'dumfunctions';
11
11
  import ExtensionBuilder from 'xernerx-extension-builder';
12
12
  import Discord from 'discord.js';
13
- const version = '4.1.0';
13
+ const version = '4.2.1';
14
14
  export { XernerxClient, MessageCommandBuilder, SlashCommandBuilder, ContextCommandBuilder, EventBuilder, InhibitorBuilder, ExtensionBuilder, Discord, version, XernerxLog };
@@ -0,0 +1,68 @@
1
+ import { ContextMenuCommandBuilder, Interaction } from 'discord.js';
2
+ import { ContextCommandOptions } from '../types/options.js';
3
+ import XernerxClient from '../client/XernerxClient.js';
4
+ /**
5
+ * @description The command builder for context commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {ContextCommandOptions} options - The command options.
8
+ */
9
+ export default class ContextCommandBuilder {
10
+ id: string;
11
+ data: ContextMenuCommandBuilder;
12
+ name: string;
13
+ type: import('@discordjs/builders').ContextMenuCommandType;
14
+ description: string | undefined;
15
+ info: string | undefined;
16
+ category: string | undefined;
17
+ channelType: number | number[] | undefined;
18
+ cooldown: number | undefined;
19
+ ignore:
20
+ | {
21
+ owner?: boolean | undefined;
22
+ users?: string[] | undefined;
23
+ channels?: string[] | undefined;
24
+ guilds?: string[] | undefined;
25
+ }
26
+ | undefined;
27
+ strict:
28
+ | {
29
+ owner?: boolean | undefined;
30
+ users?: string[] | undefined;
31
+ channels?: string[] | undefined;
32
+ guilds?: string[] | undefined;
33
+ }
34
+ | undefined;
35
+ permissions:
36
+ | {
37
+ client?: string[] | undefined;
38
+ users?: string[] | undefined;
39
+ dm?: boolean | undefined;
40
+ }
41
+ | undefined;
42
+ defer:
43
+ | {
44
+ /**
45
+ * @param {Interaction} interaction - The Discord interaction event data.
46
+ * @description Make your custom command here.
47
+ * TODO - update description
48
+ */
49
+ reply?: boolean | undefined;
50
+ ephemeral?: boolean | undefined;
51
+ fetch?: boolean | undefined;
52
+ }
53
+ | undefined;
54
+ client: typeof XernerxClient;
55
+ constructor(id: string, options: ContextCommandOptions);
56
+ /**
57
+ * @param {Interaction} interaction - The Discord interaction event data.
58
+ * @description make any preconditions here.
59
+ * TODO - update description
60
+ */
61
+ conditions(interaction: Interaction, args: any): Promise<void>;
62
+ /**
63
+ * @param {Interaction} interaction - The Discord interaction event data.
64
+ * @description Make your custom command here.
65
+ * TODO - update description
66
+ */
67
+ exec(interaction: Interaction, args: any): Promise<void>;
68
+ }
@@ -0,0 +1,88 @@
1
+ import { ContextMenuCommandBuilder } from 'discord.js';
2
+ import { z } from 'zod';
3
+ import XernerxClient from '../client/XernerxClient.js';
4
+ /**
5
+ * @description The command builder for context commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {ContextCommandOptions} options - The command options.
8
+ */
9
+ export default class ContextCommandBuilder {
10
+ id;
11
+ data;
12
+ name;
13
+ type;
14
+ description;
15
+ info;
16
+ category;
17
+ channelType;
18
+ cooldown;
19
+ ignore;
20
+ strict;
21
+ permissions;
22
+ defer;
23
+ client;
24
+ constructor(id, options) {
25
+ this.id = id;
26
+ this.data = new ContextMenuCommandBuilder();
27
+ if (options.name) this.data.setName(options.name);
28
+ if (options.type) this.data.setType(options.type);
29
+ if (options.permissions?.users) this.data.setDefaultMemberPermissions(options.permissions?.users);
30
+ if (options.permissions?.dm === false) this.data.setDMPermission(options.permissions?.dm);
31
+ if (options.nameLocalizations) this.data.setNameLocalizations(options.nameLocalizations);
32
+ z.object({
33
+ description: z.string(),
34
+ info: z.string(),
35
+ category: z.string(),
36
+ channelType: z.array(z.number()).or(z.number()),
37
+ cooldown: z.number(),
38
+ ignore: z.object({
39
+ owner: z.boolean(),
40
+ users: z.array(z.string()),
41
+ channels: z.array(z.string()),
42
+ guilds: z.array(z.string()),
43
+ }),
44
+ strict: z.object({
45
+ owner: z.boolean(),
46
+ users: z.array(z.string()),
47
+ channels: z.array(z.string()),
48
+ guilds: z.array(z.string()),
49
+ }),
50
+ permissions: z.object({
51
+ client: z.array(z.string()),
52
+ users: z.array(z.string()),
53
+ dm: z.boolean(),
54
+ }),
55
+ defer: z.object({
56
+ reply: z.boolean(),
57
+ ephemeral: z.boolean(),
58
+ fetch: z.boolean(),
59
+ }),
60
+ })
61
+ .deepPartial()
62
+ .parse(options);
63
+ this.name = options.name;
64
+ this.type = options.type;
65
+ this.description = options.description;
66
+ this.info = options.info;
67
+ this.category = options.category;
68
+ this.channelType = options.channelType;
69
+ this.cooldown = options.cooldown;
70
+ this.ignore = options.ignore;
71
+ this.strict = options.strict;
72
+ this.permissions = options.permissions;
73
+ this.defer = options.defer;
74
+ this.client = XernerxClient;
75
+ }
76
+ /**
77
+ * @param {Interaction} interaction - The Discord interaction event data.
78
+ * @description make any preconditions here.
79
+ * TODO - update description
80
+ */
81
+ async conditions(interaction, args) {}
82
+ /**
83
+ * @param {Interaction} interaction - The Discord interaction event data.
84
+ * @description Make your custom command here.
85
+ * TODO - update description
86
+ */
87
+ async exec(interaction, args) {}
88
+ }
@@ -0,0 +1,21 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { EventOptions } from '../types/options.js';
3
+ /**
4
+ * @description - The event builder for events.
5
+ * @param {String} id - The unique ID of the event.
6
+ * @param {EventOptions} options - The event options.
7
+ */
8
+ export default class EventBuilder {
9
+ id: string;
10
+ name: string;
11
+ emitter: string;
12
+ type: string;
13
+ once: boolean;
14
+ client: typeof XernerxClient;
15
+ constructor(id: string, options: EventOptions);
16
+ /**
17
+ * @description run your custom event here.
18
+ * TODO - update description
19
+ */
20
+ run(): Promise<void>;
21
+ }
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The event builder for events.
5
+ * @param {String} id - The unique ID of the event.
6
+ * @param {EventOptions} options - The event options.
7
+ */
8
+ export default class EventBuilder {
9
+ id;
10
+ name;
11
+ emitter;
12
+ type;
13
+ once;
14
+ client;
15
+ constructor(id, options) {
16
+ this.id = id;
17
+ z.object({
18
+ name: z.string(),
19
+ emitter: z.string().optional(),
20
+ type: z.string().optional(),
21
+ once: z.boolean().optional(),
22
+ }).parse(options);
23
+ this.name = options.name;
24
+ this.emitter = options.emitter || 'client';
25
+ this.type = options.type || 'discord';
26
+ this.once = options.once || false;
27
+ this.client = XernerxClient;
28
+ }
29
+ /**
30
+ * @description run your custom event here.
31
+ * TODO - update description
32
+ */
33
+ async run() {}
34
+ }
@@ -0,0 +1,19 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { InhibitorOptions, MessageArgumentOptions, SlashArgumentOptions } from '../types/options.js';
3
+ import { XernerxInteraction, XernerxMessage } from '../types/types.js';
4
+ /**
5
+ * @description - The inhibitor builder for inhibitors.
6
+ * @param {String} id - The unique ID of the inhibitor.
7
+ * @param {InhibitorOptions} options - The inhibitor options.
8
+ */
9
+ export default class InhibitorBuilder {
10
+ id: string;
11
+ name: string;
12
+ type: import('../main.js').InhibitorType;
13
+ client: typeof XernerxClient;
14
+ constructor(id: string, options: InhibitorOptions);
15
+ /**
16
+ * TODO - update description
17
+ */
18
+ check(interaction: XernerxInteraction | XernerxMessage, args: SlashArgumentOptions | MessageArgumentOptions): Promise<void>;
19
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The inhibitor builder for inhibitors.
5
+ * @param {String} id - The unique ID of the inhibitor.
6
+ * @param {InhibitorOptions} options - The inhibitor options.
7
+ */
8
+ export default class InhibitorBuilder {
9
+ id;
10
+ name;
11
+ type;
12
+ client;
13
+ constructor(id, options) {
14
+ this.id = id;
15
+ z.object({
16
+ name: z.string(),
17
+ type: z.string(),
18
+ }).parse(options);
19
+ this.name = options.name;
20
+ this.type = options.type;
21
+ this.client = XernerxClient;
22
+ }
23
+ /**
24
+ * TODO - update description
25
+ */
26
+ async check(interaction, args) {}
27
+ }
@@ -0,0 +1,59 @@
1
+ import { MessageArgumentOptions, MessageCommandOptions } from '../types/options.js';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ import { XernerxMessage } from '../types/types.js';
4
+ /**
5
+ * @description - The command builder for message commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {MessageCommandOptions} options - The command options.
8
+ */
9
+ export default class MessageCommandBuilder {
10
+ id: string;
11
+ name: string;
12
+ aliases: string[] | undefined;
13
+ separator: string;
14
+ description: string | undefined;
15
+ info: string | undefined;
16
+ category: string | undefined;
17
+ prefix: string[];
18
+ regex: string | undefined;
19
+ channelType: number[] | undefined;
20
+ ignore:
21
+ | {
22
+ owner?: boolean | undefined;
23
+ users?: string[] | undefined;
24
+ channels?: string[] | undefined;
25
+ guilds?: string[] | undefined;
26
+ }
27
+ | undefined;
28
+ strict:
29
+ | {
30
+ owner?: boolean | undefined;
31
+ users?: string[] | undefined;
32
+ channels?: string[] | undefined;
33
+ guilds?: string[] | undefined;
34
+ }
35
+ | undefined;
36
+ permissions:
37
+ | {
38
+ client?: string[] | undefined;
39
+ user?: string[] | undefined;
40
+ dm?: boolean | undefined;
41
+ }
42
+ | undefined;
43
+ cooldown: number;
44
+ args: MessageArgumentOptions[];
45
+ client: typeof XernerxClient;
46
+ constructor(id: string, options: MessageCommandOptions);
47
+ /**
48
+ * @param {Message} message - The Discord message event data.
49
+ * @param {object} args - The arguments you created.
50
+ * @description make any preconditions here.
51
+ */
52
+ conditions(message: XernerxMessage, args: MessageArgumentOptions): Promise<void>;
53
+ /**
54
+ * @param {Message} message - The Discord message event data.
55
+ * @param {object} args - The arguments you created.
56
+ * @description Make your custom command here.
57
+ */
58
+ exec(message: XernerxMessage, args: MessageArgumentOptions): Promise<void>;
59
+ }
@@ -0,0 +1,90 @@
1
+ import { z } from 'zod';
2
+ import XernerxClient from '../client/XernerxClient.js';
3
+ /**
4
+ * @description - The command builder for message commands.
5
+ * @param {String} id - The unique ID of the command.
6
+ * @param {MessageCommandOptions} options - The command options.
7
+ */
8
+ export default class MessageCommandBuilder {
9
+ id;
10
+ name;
11
+ aliases;
12
+ separator;
13
+ description;
14
+ info;
15
+ category;
16
+ prefix;
17
+ regex;
18
+ channelType;
19
+ ignore;
20
+ strict;
21
+ permissions;
22
+ cooldown;
23
+ args;
24
+ client;
25
+ constructor(id, options) {
26
+ this.id = id;
27
+ z.object({
28
+ name: z.string(),
29
+ aliases: z.array(z.string()).optional(),
30
+ separator: z.string().min(1).max(1).optional(),
31
+ description: z.string().optional(),
32
+ info: z.string().optional(),
33
+ category: z.string().optional(),
34
+ prefix: z.array(z.string()).or(z.string()).optional(),
35
+ regex: z.unknown(),
36
+ channelType: z.array(z.number()).or(z.number()).optional(),
37
+ cooldown: z.number().optional(),
38
+ ignore: z
39
+ .object({
40
+ owners: z.boolean().optional(),
41
+ users: z.array(z.string()).or(z.string()).optional(),
42
+ channels: z.array(z.string()).or(z.string()).optional(),
43
+ guilds: z.array(z.string()).or(z.string()).optional(),
44
+ })
45
+ .optional(),
46
+ strict: z
47
+ .object({
48
+ owners: z.boolean().optional(),
49
+ users: z.array(z.string()).or(z.string()).optional(),
50
+ channels: z.array(z.string()).or(z.string()).optional(),
51
+ guilds: z.array(z.string()).or(z.string()).optional(),
52
+ })
53
+ .optional(),
54
+ permissions: z
55
+ .object({
56
+ client: z.array(z.string()).optional(),
57
+ users: z.array(z.string()).optional(),
58
+ dm: z.boolean().optional(),
59
+ })
60
+ .optional(),
61
+ }).parse(options);
62
+ this.name = options.name;
63
+ this.aliases = options.aliases;
64
+ this.separator = options.separator || ' ';
65
+ this.description = options.description;
66
+ this.info = options.info;
67
+ this.category = options.category;
68
+ this.prefix = options.prefix ? (Array.isArray(options.prefix) ? options.prefix : [options.prefix]) : [];
69
+ this.regex = options.regex;
70
+ this.channelType = options.channelType;
71
+ this.ignore = options.ignore;
72
+ this.strict = options.strict;
73
+ this.permissions = options.permissions;
74
+ this.cooldown = options.cooldown || 0;
75
+ this.args = options.args || [];
76
+ this.client = XernerxClient;
77
+ }
78
+ /**
79
+ * @param {Message} message - The Discord message event data.
80
+ * @param {object} args - The arguments you created.
81
+ * @description make any preconditions here.
82
+ */
83
+ async conditions(message, args) {}
84
+ /**
85
+ * @param {Message} message - The Discord message event data.
86
+ * @param {object} args - The arguments you created.
87
+ * @description Make your custom command here.
88
+ */
89
+ async exec(message, args) {}
90
+ }
@@ -0,0 +1,64 @@
1
+ import Discord, { Interaction } from 'discord.js';
2
+ import { SlashCommandOptions } from '../types/options.js';
3
+ import XernerxClient from '../client/XernerxClient.js';
4
+ /**
5
+ * @description - The command builder for slash commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {SlashCommandOptions} options - The command options.
8
+ */
9
+ export default class SlashCommandBuilder {
10
+ id: string;
11
+ data: Discord.SlashCommandBuilder;
12
+ name: string;
13
+ description: string;
14
+ info: string | undefined;
15
+ category: string | undefined;
16
+ channelType: Discord.ChannelType | undefined;
17
+ cooldown: number | undefined;
18
+ ignore:
19
+ | {
20
+ owner?: boolean | undefined;
21
+ users?: string[] | undefined;
22
+ channels?: string[] | undefined;
23
+ guilds?: string[] | undefined;
24
+ }
25
+ | undefined;
26
+ strict:
27
+ | {
28
+ owner?: boolean | undefined;
29
+ users?: string[] | undefined;
30
+ channels?: string[] | undefined;
31
+ guilds?: string[] | undefined;
32
+ }
33
+ | undefined;
34
+ permissions: {
35
+ client?: string[] | undefined;
36
+ users?: string[] | undefined;
37
+ dm?: boolean | undefined;
38
+ };
39
+ args?: object[];
40
+ subcommands?: object[];
41
+ groups?: object[];
42
+ defer:
43
+ | {
44
+ reply?: boolean | undefined;
45
+ ephemeral?: boolean | undefined;
46
+ fetchReply?: boolean | undefined;
47
+ }
48
+ | undefined;
49
+ client: typeof XernerxClient;
50
+ constructor(id: string, options: SlashCommandOptions);
51
+ /**
52
+ * TODO - update description
53
+ * @param interaction
54
+ */
55
+ conditions(interaction: Interaction): Promise<void>;
56
+ /**
57
+ * TODO - update description
58
+ * @param interaction
59
+ */
60
+ exec(interaction: Interaction): Promise<void>;
61
+ private addArgs;
62
+ private addSubcommands;
63
+ private addSubcommandGroups;
64
+ }