reciple 6.0.0-dev.25 → 6.0.0-dev.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.
Files changed (46) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +183 -183
  3. package/dist/lib/bin.mjs +67 -66
  4. package/dist/lib/esm.mjs +1 -1
  5. package/dist/lib/index.js +33 -33
  6. package/dist/lib/reciple/classes/RecipleClient.js +307 -296
  7. package/dist/lib/reciple/classes/RecipleConfig.js +106 -106
  8. package/dist/lib/reciple/classes/RecipleModule.js +94 -94
  9. package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +309 -309
  10. package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +126 -126
  11. package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +246 -246
  12. package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +178 -178
  13. package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +99 -99
  14. package/dist/lib/reciple/classes/managers/CommandManager.js +60 -59
  15. package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
  16. package/dist/lib/reciple/classes/managers/ModuleManager.js +176 -176
  17. package/dist/lib/reciple/flags.js +31 -31
  18. package/dist/lib/reciple/permissions.js +30 -30
  19. package/dist/lib/reciple/types/builders.js +11 -11
  20. package/dist/lib/reciple/types/commands.js +15 -15
  21. package/dist/lib/reciple/types/paramOptions.js +2 -2
  22. package/dist/lib/reciple/util.js +71 -69
  23. package/dist/lib/reciple/version.js +47 -47
  24. package/dist/types/bin.d.mts +2 -2
  25. package/dist/types/esm.d.mts +1 -1
  26. package/dist/types/index.d.ts +17 -17
  27. package/dist/types/reciple/classes/RecipleClient.d.ts +114 -104
  28. package/dist/types/reciple/classes/RecipleConfig.d.ts +100 -100
  29. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -56
  30. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +189 -189
  31. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +53 -53
  32. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +98 -98
  33. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +53 -53
  34. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +70 -70
  35. package/dist/types/reciple/classes/managers/CommandManager.d.ts +34 -34
  36. package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +22 -22
  37. package/dist/types/reciple/classes/managers/ModuleManager.d.ts +49 -49
  38. package/dist/types/reciple/flags.d.ts +17 -17
  39. package/dist/types/reciple/permissions.d.ts +15 -15
  40. package/dist/types/reciple/types/builders.d.ts +205 -205
  41. package/dist/types/reciple/types/commands.d.ts +81 -81
  42. package/dist/types/reciple/types/paramOptions.d.ts +101 -101
  43. package/dist/types/reciple/util.d.ts +26 -26
  44. package/dist/types/reciple/version.d.ts +25 -25
  45. package/package.json +2 -2
  46. package/resource/reciple.yml +120 -120
@@ -1,309 +1,309 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageCommandBuilder = void 0;
4
- const builders_1 = require("../../types/builders");
5
- const discord_js_1 = require("discord.js");
6
- const MessageCommandOptionManager_1 = require("../managers/MessageCommandOptionManager");
7
- const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
8
- /**
9
- * Reciple builder for message command
10
- */
11
- class MessageCommandBuilder {
12
- constructor(data) {
13
- this.type = builders_1.CommandType.MessageCommand;
14
- this._name = '';
15
- this._description = '';
16
- this._cooldown = 0;
17
- this._aliases = [];
18
- this._validateOptions = false;
19
- this._options = [];
20
- this._requiredBotPermissions = [];
21
- this._requiredMemberPermissions = [];
22
- this._allowExecuteInDM = true;
23
- this._allowExecuteByBots = false;
24
- this._execute = () => {
25
- /* Execute */
26
- };
27
- if (data?.name !== undefined)
28
- this.setName(data.name);
29
- if (data?.description !== undefined)
30
- this.setDescription(data.description);
31
- if (data?.aliases !== undefined)
32
- this.addAliases(data.aliases);
33
- if (data?.cooldown !== undefined)
34
- this.setCooldown(Number(data?.cooldown));
35
- if (data?.requiredBotPermissions !== undefined)
36
- this.setRequiredBotPermissions(data.requiredBotPermissions);
37
- if (data?.requiredMemberPermissions !== undefined)
38
- this.setRequiredMemberPermissions(data.requiredMemberPermissions);
39
- if (data?.halt !== undefined)
40
- this.setHalt(data.halt);
41
- if (data?.execute !== undefined)
42
- this.setExecute(data.execute);
43
- if (data?.metadata !== undefined)
44
- this.setMetadata(data.metadata);
45
- if (data?.allowExecuteByBots !== undefined)
46
- this.setAllowExecuteByBots(true);
47
- if (data?.allowExecuteInDM !== undefined)
48
- this.setAllowExecuteInDM(true);
49
- if (data?.validateOptions !== undefined)
50
- this.setValidateOptions(true);
51
- if (data?.options !== undefined)
52
- this.options = data.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o)));
53
- }
54
- get name() {
55
- return this._name;
56
- }
57
- get description() {
58
- return this._description;
59
- }
60
- get cooldown() {
61
- return this._cooldown;
62
- }
63
- get aliases() {
64
- return this._aliases;
65
- }
66
- get validateOptions() {
67
- return this._validateOptions;
68
- }
69
- get options() {
70
- return this._options;
71
- }
72
- get requiredBotPermissions() {
73
- return this._requiredBotPermissions;
74
- }
75
- get requiredMemberPermissions() {
76
- return this._requiredMemberPermissions;
77
- }
78
- get allowExecuteInDM() {
79
- return this._allowExecuteInDM;
80
- }
81
- get allowExecuteByBots() {
82
- return this._allowExecuteByBots;
83
- }
84
- get halt() {
85
- return this._halt;
86
- }
87
- get execute() {
88
- return this._execute;
89
- }
90
- set name(name) {
91
- this.setName(name);
92
- }
93
- set description(description) {
94
- this.setDescription(description);
95
- }
96
- set cooldown(cooldown) {
97
- this.setCooldown(cooldown);
98
- }
99
- set aliases(aliases) {
100
- this.addAliases(aliases);
101
- }
102
- set validateOptions(validate) {
103
- this.setValidateOptions(validate);
104
- }
105
- set options(options) {
106
- this.setOptions(options);
107
- }
108
- set requiredBotPermissions(permissions) {
109
- this.setRequiredBotPermissions(permissions);
110
- }
111
- set requiredMemberPermissions(permissions) {
112
- this.setRequiredMemberPermissions(permissions);
113
- }
114
- set allowExecuteInDM(allow) {
115
- this.setAllowExecuteInDM(allow);
116
- }
117
- set allowExecuteByBots(allow) {
118
- this.setAllowExecuteByBots(allow);
119
- }
120
- set halt(halt) {
121
- this.setHalt(halt);
122
- }
123
- set execute(execute) {
124
- this.setExecute(execute);
125
- }
126
- /**
127
- * Sets the command name
128
- * @param name Command name
129
- */
130
- setName(name) {
131
- if ((0, discord_js_1.isValidationEnabled)() && (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
132
- throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
133
- this._name = name;
134
- return this;
135
- }
136
- /**
137
- * Sets the command description
138
- * @param description Command description
139
- */
140
- setDescription(description) {
141
- if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
142
- throw new TypeError('description must be a string.');
143
- this._description = description;
144
- return this;
145
- }
146
- /**
147
- * Add aliases to the command
148
- * @param aliases Command aliases
149
- */
150
- addAliases(...aliases) {
151
- aliases = (0, discord_js_1.normalizeArray)(aliases);
152
- if (!aliases.length)
153
- throw new TypeError('Provide atleast one alias');
154
- if (aliases.some(a => !a || typeof a !== 'string' || a.match(/^\s+$/)))
155
- throw new TypeError('aliases must be strings and should not contain whitespaces');
156
- if (this.name && aliases.some(a => a == this.name))
157
- throw new TypeError('alias cannot have same name to its real command name');
158
- this._aliases = [...new Set(aliases.map(s => s.toLowerCase()))];
159
- return this;
160
- }
161
- /**
162
- * Replace aliases from command builder
163
- * @param aliases Command aliases
164
- */
165
- setAliases(...aliases) {
166
- this._aliases = [];
167
- return this.addAliases(...aliases);
168
- }
169
- /**
170
- * Set if command can be executed in dms
171
- * @param allowExecuteInDM `true` if the command can execute in DMs
172
- */
173
- setAllowExecuteInDM(allowExecuteInDM) {
174
- this._allowExecuteInDM = !!allowExecuteInDM;
175
- return this;
176
- }
177
- /**
178
- * Allow command to be executed by bots
179
- * @param allowExecuteByBots `true` if the command can be executed by bots
180
- */
181
- setAllowExecuteByBots(allowExecuteByBots) {
182
- this._allowExecuteByBots = !!allowExecuteByBots;
183
- return this;
184
- }
185
- /**
186
- * Add new command options
187
- * @param options Message options
188
- */
189
- addOptions(...options) {
190
- for (const optionResolvable of (0, discord_js_1.normalizeArray)(options)) {
191
- const option = typeof optionResolvable === 'function' ? optionResolvable(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : optionResolvable instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? optionResolvable : MessageCommandOptionBuilder_1.MessageCommandOptionBuilder.resolveMessageCommandOption(optionResolvable);
192
- if ((0, discord_js_1.isValidationEnabled)()) {
193
- if (this.options.find(o => o.name === option.name))
194
- throw new TypeError('option with name "' + option.name + '" already exists.');
195
- if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
196
- throw new TypeError('All required options must be before optional options.');
197
- }
198
- this._options.push(option);
199
- }
200
- return this;
201
- }
202
- /**
203
- * Add new command option
204
- * @param option Message option
205
- */
206
- addOption(option) {
207
- return this.addOptions(option);
208
- }
209
- /**
210
- * Set options from command
211
- * @params options Message options
212
- */
213
- setOptions(...options) {
214
- this._options = [];
215
- return this.addOptions(...options);
216
- }
217
- /**
218
- * Validate options before executing
219
- * @param validateOptions `true` if the command options needs to be validated before executing
220
- */
221
- setValidateOptions(validateOptions) {
222
- this._validateOptions = !!validateOptions;
223
- return this;
224
- }
225
- setCooldown(cooldown) {
226
- this._cooldown = cooldown;
227
- return this;
228
- }
229
- setRequiredBotPermissions(...permissions) {
230
- this._requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
231
- return this;
232
- }
233
- setRequiredMemberPermissions(...permissions) {
234
- this._requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
235
- return this;
236
- }
237
- setHalt(halt) {
238
- this._halt = halt || undefined;
239
- return this;
240
- }
241
- setExecute(execute) {
242
- if ((0, discord_js_1.isValidationEnabled)() && (!execute || typeof execute !== 'function'))
243
- throw new TypeError('execute must be a function.');
244
- this._execute = execute;
245
- return this;
246
- }
247
- setMetadata(metadata) {
248
- this.metadata = metadata;
249
- return this;
250
- }
251
- /**
252
- * Returns JSON object of this builder
253
- */
254
- toJSON() {
255
- return {
256
- type: this.type,
257
- name: this.name,
258
- description: this.description,
259
- aliases: this.aliases,
260
- cooldown: this.cooldown,
261
- requiredBotPermissions: this.requiredBotPermissions,
262
- requiredMemberPermissions: this.requiredMemberPermissions,
263
- halt: this.halt,
264
- execute: this.execute,
265
- metadata: this.metadata,
266
- allowExecuteByBots: this.allowExecuteByBots,
267
- allowExecuteInDM: this.allowExecuteInDM,
268
- validateOptions: this.validateOptions,
269
- options: this.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o.toJSON() : o)),
270
- };
271
- }
272
- /**
273
- * Resolve message command data/builder
274
- * @param commandData Command data to resolve
275
- */
276
- static resolveMessageCommand(commandData) {
277
- return this.isMessageCommandBuilder(commandData) ? commandData : new MessageCommandBuilder(commandData);
278
- }
279
- /**
280
- * Is a message command builder
281
- * @param builder data to check
282
- */
283
- static isMessageCommandBuilder(builder) {
284
- return builder instanceof MessageCommandBuilder;
285
- }
286
- /**
287
- * Is a message command execute data
288
- * @param executeData data to check
289
- */
290
- static isMessageCommandExecuteData(executeData) {
291
- return executeData.builder !== undefined && this.isMessageCommandBuilder(executeData.builder);
292
- }
293
- /**
294
- * Validate message command options
295
- * @param builder Command builder
296
- * @param options Parsed command args
297
- */
298
- static async validateOptions(builder, commandArgs) {
299
- const args = Array.isArray(commandArgs) ? commandArgs : commandArgs.args || [];
300
- const allOptions = [...(builder.options ?? []).filter(o => o.required), ...(builder.options ?? []).filter(o => !o.required)];
301
- const result = [];
302
- for (let i = 0; i < allOptions.length; i++) {
303
- const arg = args[i];
304
- result.push(await MessageCommandOptionBuilder_1.MessageCommandOptionBuilder.validateOption(allOptions[i], arg));
305
- }
306
- return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
307
- }
308
- }
309
- exports.MessageCommandBuilder = MessageCommandBuilder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageCommandBuilder = void 0;
4
+ const builders_1 = require("../../types/builders");
5
+ const discord_js_1 = require("discord.js");
6
+ const MessageCommandOptionManager_1 = require("../managers/MessageCommandOptionManager");
7
+ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
8
+ /**
9
+ * Reciple builder for message command
10
+ */
11
+ class MessageCommandBuilder {
12
+ constructor(data) {
13
+ this.type = builders_1.CommandType.MessageCommand;
14
+ this._name = '';
15
+ this._description = '';
16
+ this._cooldown = 0;
17
+ this._aliases = [];
18
+ this._validateOptions = false;
19
+ this._options = [];
20
+ this._requiredBotPermissions = [];
21
+ this._requiredMemberPermissions = [];
22
+ this._allowExecuteInDM = true;
23
+ this._allowExecuteByBots = false;
24
+ this._execute = () => {
25
+ /* Execute */
26
+ };
27
+ if (data?.name !== undefined)
28
+ this.setName(data.name);
29
+ if (data?.description !== undefined)
30
+ this.setDescription(data.description);
31
+ if (data?.aliases !== undefined)
32
+ this.addAliases(data.aliases);
33
+ if (data?.cooldown !== undefined)
34
+ this.setCooldown(Number(data?.cooldown));
35
+ if (data?.requiredBotPermissions !== undefined)
36
+ this.setRequiredBotPermissions(data.requiredBotPermissions);
37
+ if (data?.requiredMemberPermissions !== undefined)
38
+ this.setRequiredMemberPermissions(data.requiredMemberPermissions);
39
+ if (data?.halt !== undefined)
40
+ this.setHalt(data.halt);
41
+ if (data?.execute !== undefined)
42
+ this.setExecute(data.execute);
43
+ if (data?.metadata !== undefined)
44
+ this.setMetadata(data.metadata);
45
+ if (data?.allowExecuteByBots !== undefined)
46
+ this.setAllowExecuteByBots(true);
47
+ if (data?.allowExecuteInDM !== undefined)
48
+ this.setAllowExecuteInDM(true);
49
+ if (data?.validateOptions !== undefined)
50
+ this.setValidateOptions(true);
51
+ if (data?.options !== undefined)
52
+ this.options = data.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o)));
53
+ }
54
+ get name() {
55
+ return this._name;
56
+ }
57
+ get description() {
58
+ return this._description;
59
+ }
60
+ get cooldown() {
61
+ return this._cooldown;
62
+ }
63
+ get aliases() {
64
+ return this._aliases;
65
+ }
66
+ get validateOptions() {
67
+ return this._validateOptions;
68
+ }
69
+ get options() {
70
+ return this._options;
71
+ }
72
+ get requiredBotPermissions() {
73
+ return this._requiredBotPermissions;
74
+ }
75
+ get requiredMemberPermissions() {
76
+ return this._requiredMemberPermissions;
77
+ }
78
+ get allowExecuteInDM() {
79
+ return this._allowExecuteInDM;
80
+ }
81
+ get allowExecuteByBots() {
82
+ return this._allowExecuteByBots;
83
+ }
84
+ get halt() {
85
+ return this._halt;
86
+ }
87
+ get execute() {
88
+ return this._execute;
89
+ }
90
+ set name(name) {
91
+ this.setName(name);
92
+ }
93
+ set description(description) {
94
+ this.setDescription(description);
95
+ }
96
+ set cooldown(cooldown) {
97
+ this.setCooldown(cooldown);
98
+ }
99
+ set aliases(aliases) {
100
+ this.addAliases(aliases);
101
+ }
102
+ set validateOptions(validate) {
103
+ this.setValidateOptions(validate);
104
+ }
105
+ set options(options) {
106
+ this.setOptions(options);
107
+ }
108
+ set requiredBotPermissions(permissions) {
109
+ this.setRequiredBotPermissions(permissions);
110
+ }
111
+ set requiredMemberPermissions(permissions) {
112
+ this.setRequiredMemberPermissions(permissions);
113
+ }
114
+ set allowExecuteInDM(allow) {
115
+ this.setAllowExecuteInDM(allow);
116
+ }
117
+ set allowExecuteByBots(allow) {
118
+ this.setAllowExecuteByBots(allow);
119
+ }
120
+ set halt(halt) {
121
+ this.setHalt(halt);
122
+ }
123
+ set execute(execute) {
124
+ this.setExecute(execute);
125
+ }
126
+ /**
127
+ * Sets the command name
128
+ * @param name Command name
129
+ */
130
+ setName(name) {
131
+ if ((0, discord_js_1.isValidationEnabled)() && (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
132
+ throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
133
+ this._name = name;
134
+ return this;
135
+ }
136
+ /**
137
+ * Sets the command description
138
+ * @param description Command description
139
+ */
140
+ setDescription(description) {
141
+ if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
142
+ throw new TypeError('description must be a string.');
143
+ this._description = description;
144
+ return this;
145
+ }
146
+ /**
147
+ * Add aliases to the command
148
+ * @param aliases Command aliases
149
+ */
150
+ addAliases(...aliases) {
151
+ aliases = (0, discord_js_1.normalizeArray)(aliases);
152
+ if (!aliases.length)
153
+ throw new TypeError('Provide atleast one alias');
154
+ if (aliases.some(a => !a || typeof a !== 'string' || a.match(/^\s+$/)))
155
+ throw new TypeError('aliases must be strings and should not contain whitespaces');
156
+ if (this.name && aliases.some(a => a == this.name))
157
+ throw new TypeError('alias cannot have same name to its real command name');
158
+ this._aliases = [...new Set(aliases.map(s => s.toLowerCase()))];
159
+ return this;
160
+ }
161
+ /**
162
+ * Replace aliases from command builder
163
+ * @param aliases Command aliases
164
+ */
165
+ setAliases(...aliases) {
166
+ this._aliases = [];
167
+ return this.addAliases(...aliases);
168
+ }
169
+ /**
170
+ * Set if command can be executed in dms
171
+ * @param allowExecuteInDM `true` if the command can execute in DMs
172
+ */
173
+ setAllowExecuteInDM(allowExecuteInDM) {
174
+ this._allowExecuteInDM = !!allowExecuteInDM;
175
+ return this;
176
+ }
177
+ /**
178
+ * Allow command to be executed by bots
179
+ * @param allowExecuteByBots `true` if the command can be executed by bots
180
+ */
181
+ setAllowExecuteByBots(allowExecuteByBots) {
182
+ this._allowExecuteByBots = !!allowExecuteByBots;
183
+ return this;
184
+ }
185
+ /**
186
+ * Add new command options
187
+ * @param options Message options
188
+ */
189
+ addOptions(...options) {
190
+ for (const optionResolvable of (0, discord_js_1.normalizeArray)(options)) {
191
+ const option = typeof optionResolvable === 'function' ? optionResolvable(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : optionResolvable instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? optionResolvable : MessageCommandOptionBuilder_1.MessageCommandOptionBuilder.resolveMessageCommandOption(optionResolvable);
192
+ if ((0, discord_js_1.isValidationEnabled)()) {
193
+ if (this.options.find(o => o.name === option.name))
194
+ throw new TypeError('option with name "' + option.name + '" already exists.');
195
+ if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
196
+ throw new TypeError('All required options must be before optional options.');
197
+ }
198
+ this._options.push(option);
199
+ }
200
+ return this;
201
+ }
202
+ /**
203
+ * Add new command option
204
+ * @param option Message option
205
+ */
206
+ addOption(option) {
207
+ return this.addOptions(option);
208
+ }
209
+ /**
210
+ * Set options from command
211
+ * @params options Message options
212
+ */
213
+ setOptions(...options) {
214
+ this._options = [];
215
+ return this.addOptions(...options);
216
+ }
217
+ /**
218
+ * Validate options before executing
219
+ * @param validateOptions `true` if the command options needs to be validated before executing
220
+ */
221
+ setValidateOptions(validateOptions) {
222
+ this._validateOptions = !!validateOptions;
223
+ return this;
224
+ }
225
+ setCooldown(cooldown) {
226
+ this._cooldown = cooldown;
227
+ return this;
228
+ }
229
+ setRequiredBotPermissions(...permissions) {
230
+ this._requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
231
+ return this;
232
+ }
233
+ setRequiredMemberPermissions(...permissions) {
234
+ this._requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
235
+ return this;
236
+ }
237
+ setHalt(halt) {
238
+ this._halt = halt || undefined;
239
+ return this;
240
+ }
241
+ setExecute(execute) {
242
+ if ((0, discord_js_1.isValidationEnabled)() && (!execute || typeof execute !== 'function'))
243
+ throw new TypeError('execute must be a function.');
244
+ this._execute = execute;
245
+ return this;
246
+ }
247
+ setMetadata(metadata) {
248
+ this.metadata = metadata;
249
+ return this;
250
+ }
251
+ /**
252
+ * Returns JSON object of this builder
253
+ */
254
+ toJSON() {
255
+ return {
256
+ type: this.type,
257
+ name: this.name,
258
+ description: this.description,
259
+ aliases: this.aliases,
260
+ cooldown: this.cooldown,
261
+ requiredBotPermissions: this.requiredBotPermissions,
262
+ requiredMemberPermissions: this.requiredMemberPermissions,
263
+ halt: this.halt,
264
+ execute: this.execute,
265
+ metadata: this.metadata,
266
+ allowExecuteByBots: this.allowExecuteByBots,
267
+ allowExecuteInDM: this.allowExecuteInDM,
268
+ validateOptions: this.validateOptions,
269
+ options: this.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o.toJSON() : o)),
270
+ };
271
+ }
272
+ /**
273
+ * Resolve message command data/builder
274
+ * @param commandData Command data to resolve
275
+ */
276
+ static resolveMessageCommand(commandData) {
277
+ return this.isMessageCommandBuilder(commandData) ? commandData : new MessageCommandBuilder(commandData);
278
+ }
279
+ /**
280
+ * Is a message command builder
281
+ * @param builder data to check
282
+ */
283
+ static isMessageCommandBuilder(builder) {
284
+ return builder instanceof MessageCommandBuilder;
285
+ }
286
+ /**
287
+ * Is a message command execute data
288
+ * @param executeData data to check
289
+ */
290
+ static isMessageCommandExecuteData(executeData) {
291
+ return executeData.builder !== undefined && this.isMessageCommandBuilder(executeData.builder);
292
+ }
293
+ /**
294
+ * Validate message command options
295
+ * @param builder Command builder
296
+ * @param options Parsed command args
297
+ */
298
+ static async validateOptions(builder, commandArgs) {
299
+ const args = Array.isArray(commandArgs) ? commandArgs : commandArgs.args || [];
300
+ const allOptions = [...(builder.options ?? []).filter(o => o.required), ...(builder.options ?? []).filter(o => !o.required)];
301
+ const result = [];
302
+ for (let i = 0; i < allOptions.length; i++) {
303
+ const arg = args[i];
304
+ result.push(await MessageCommandOptionBuilder_1.MessageCommandOptionBuilder.validateOption(allOptions[i], arg));
305
+ }
306
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
307
+ }
308
+ }
309
+ exports.MessageCommandBuilder = MessageCommandBuilder;