reciple 6.0.0-dev.20 → 6.0.0-dev.22

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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RecipleClient = void 0;
4
- const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
5
4
  const discord_js_1 = require("discord.js");
5
+ const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
6
6
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
7
7
  const commands_1 = require("../types/commands");
8
8
  const CommandCooldownManager_1 = require("./managers/CommandCooldownManager");
@@ -135,7 +135,7 @@ class RecipleClient extends discord_js_1.Client {
135
135
  const command = this.commands.get(parseCommand.command, builders_1.CommandType.MessageCommand);
136
136
  if (!command)
137
137
  return;
138
- const commandOptions = await (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
138
+ const commandOptions = await MessageCommandBuilder_1.MessageCommandBuilder.validateOptions(command, parseCommand);
139
139
  const executeData = {
140
140
  message: message,
141
141
  options: commandOptions,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
3
+ exports.MessageCommandBuilder = void 0;
4
4
  const builders_1 = require("../../types/builders");
5
5
  const discord_js_1 = require("discord.js");
6
6
  const MessageCommandOptionManager_1 = require("../managers/MessageCommandOptionManager");
@@ -11,17 +11,17 @@ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
11
11
  class MessageCommandBuilder {
12
12
  constructor(data) {
13
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 = () => {
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
25
  /* Execute */
26
26
  };
27
27
  if (data?.name !== undefined)
@@ -51,14 +51,86 @@ class MessageCommandBuilder {
51
51
  if (data?.options !== undefined)
52
52
  this.options = data.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o)));
53
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
+ }
54
126
  /**
55
127
  * Sets the command name
56
128
  * @param name Command name
57
129
  */
58
130
  setName(name) {
59
- if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
131
+ if ((0, discord_js_1.isValidationEnabled)() && (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
60
132
  throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
61
- this.name = name;
133
+ this._name = name;
62
134
  return this;
63
135
  }
64
136
  /**
@@ -66,9 +138,9 @@ class MessageCommandBuilder {
66
138
  * @param description Command description
67
139
  */
68
140
  setDescription(description) {
69
- if (!description || typeof description !== 'string')
141
+ if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
70
142
  throw new TypeError('description must be a string.');
71
- this.description = description;
143
+ this._description = description;
72
144
  return this;
73
145
  }
74
146
  /**
@@ -83,17 +155,23 @@ class MessageCommandBuilder {
83
155
  throw new TypeError('aliases must be strings and should not contain whitespaces');
84
156
  if (this.name && aliases.some(a => a == this.name))
85
157
  throw new TypeError('alias cannot have same name to its real command name');
86
- this.aliases = [...new Set(aliases.map(s => s.toLowerCase()))];
158
+ this._aliases = [...new Set(aliases.map(s => s.toLowerCase()))];
87
159
  return this;
88
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
+ }
89
169
  /**
90
170
  * Set if command can be executed in dms
91
171
  * @param allowExecuteInDM `true` if the command can execute in DMs
92
172
  */
93
173
  setAllowExecuteInDM(allowExecuteInDM) {
94
- if (typeof allowExecuteInDM !== 'boolean')
95
- throw new TypeError('allowExecuteInDM must be a boolean.');
96
- this.allowExecuteInDM = allowExecuteInDM;
174
+ this._allowExecuteInDM = !!allowExecuteInDM;
97
175
  return this;
98
176
  }
99
177
  /**
@@ -101,56 +179,62 @@ class MessageCommandBuilder {
101
179
  * @param allowExecuteByBots `true` if the command can be executed by bots
102
180
  */
103
181
  setAllowExecuteByBots(allowExecuteByBots) {
104
- if (typeof allowExecuteByBots !== 'boolean')
105
- throw new TypeError('allowExecuteByBots must be a boolean.');
106
- this.allowExecuteByBots = allowExecuteByBots;
182
+ this._allowExecuteByBots = !!allowExecuteByBots;
107
183
  return this;
108
184
  }
109
185
  /**
110
- * Add option to the command
111
- * @param option Message option builder
186
+ * Add options to command
187
+ * @param options Message options
112
188
  */
113
- addOption(option) {
114
- if (!option)
115
- throw new TypeError('option must be a MessageOption.');
116
- option = typeof option === 'function' ? option(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : option;
117
- if (this.options.find(o => o.name === option.name))
118
- throw new TypeError('option with name "' + option.name + '" already exists.');
119
- if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
120
- throw new TypeError('All required options must be before optional options.');
121
- this.options.push(option);
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
+ }
122
200
  return this;
123
201
  }
202
+ /**
203
+ * Replace options from command
204
+ * @params options Message options
205
+ */
206
+ setOptions(...options) {
207
+ this._options = [];
208
+ return this.addOptions(...options);
209
+ }
124
210
  /**
125
211
  * Validate options before executing
126
212
  * @param validateOptions `true` if the command options needs to be validated before executing
127
213
  */
128
214
  setValidateOptions(validateOptions) {
129
- if (typeof validateOptions !== 'boolean')
130
- throw new TypeError('validateOptions must be a boolean.');
131
- this.validateOptions = validateOptions;
215
+ this._validateOptions = !!validateOptions;
132
216
  return this;
133
217
  }
134
218
  setCooldown(cooldown) {
135
- this.cooldown = cooldown;
219
+ this._cooldown = cooldown;
136
220
  return this;
137
221
  }
138
222
  setRequiredBotPermissions(...permissions) {
139
- this.requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
223
+ this._requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
140
224
  return this;
141
225
  }
142
226
  setRequiredMemberPermissions(...permissions) {
143
- this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
227
+ this._requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
144
228
  return this;
145
229
  }
146
230
  setHalt(halt) {
147
- this.halt = halt ?? undefined;
231
+ this._halt = halt || undefined;
148
232
  return this;
149
233
  }
150
234
  setExecute(execute) {
151
- if (!execute || typeof execute !== 'function')
235
+ if ((0, discord_js_1.isValidationEnabled)() && (!execute || typeof execute !== 'function'))
152
236
  throw new TypeError('execute must be a function.');
153
- this.execute = execute;
237
+ this._execute = execute;
154
238
  return this;
155
239
  }
156
240
  setMetadata(metadata) {
@@ -175,7 +259,7 @@ class MessageCommandBuilder {
175
259
  allowExecuteByBots: this.allowExecuteByBots,
176
260
  allowExecuteInDM: this.allowExecuteInDM,
177
261
  validateOptions: this.validateOptions,
178
- options: this.options.map(o => o.toJSON()),
262
+ options: this.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o.toJSON() : o)),
179
263
  };
180
264
  }
181
265
  /**
@@ -199,44 +283,43 @@ class MessageCommandBuilder {
199
283
  static isMessageCommandExecuteData(executeData) {
200
284
  return executeData.builder !== undefined && this.isMessageCommandBuilder(executeData.builder);
201
285
  }
202
- }
203
- exports.MessageCommandBuilder = MessageCommandBuilder;
204
- /**
205
- * Validate message command options
206
- * @param builder Command builder
207
- * @param options Parsed command args
208
- */
209
- async function validateMessageCommandOptions(builder, options) {
210
- const args = options.args || [];
211
- const required = builder.options.filter(o => o.required);
212
- const optional = builder.options.filter(o => !o.required);
213
- const allOptions = [...required, ...optional];
214
- const result = [];
215
- let i = 0;
216
- for (const option of allOptions) {
217
- const arg = args[i];
218
- const value = {
219
- name: option.name,
220
- value: arg ?? undefined,
221
- required: option.required,
222
- invalid: false,
223
- missing: false,
224
- };
225
- if (arg == undefined && option.required) {
226
- value.missing = true;
227
- result.push(value);
228
- continue;
229
- }
230
- if (arg == undefined && !option.required) {
286
+ /**
287
+ * Validate message command options
288
+ * @param builder Command builder
289
+ * @param options Parsed command args
290
+ */
291
+ static async validateOptions(builder, options) {
292
+ const args = options.args || [];
293
+ const required = builder.options.filter(o => o.required);
294
+ const optional = builder.options.filter(o => !o.required);
295
+ const allOptions = [...required, ...optional];
296
+ const result = [];
297
+ let i = 0;
298
+ for (const option of allOptions) {
299
+ const arg = args[i];
300
+ const value = {
301
+ name: option.name,
302
+ value: arg ?? undefined,
303
+ required: !!option.required,
304
+ invalid: false,
305
+ missing: false,
306
+ };
307
+ if (arg == undefined && option.required) {
308
+ value.missing = true;
309
+ result.push(value);
310
+ continue;
311
+ }
312
+ if (arg == undefined && !option.required) {
313
+ result.push(value);
314
+ continue;
315
+ }
316
+ const validate = option.validator ? await Promise.resolve(option.validator(arg)) : true;
317
+ if (!validate)
318
+ value.invalid = true;
231
319
  result.push(value);
232
- continue;
320
+ i++;
233
321
  }
234
- const validate = option.validator ? await Promise.resolve(option.validator(arg)) : true;
235
- if (!validate)
236
- value.invalid = true;
237
- result.push(value);
238
- i++;
322
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
239
323
  }
240
- return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
241
324
  }
242
- exports.validateMessageCommandOptions = validateMessageCommandOptions;
325
+ exports.MessageCommandBuilder = MessageCommandBuilder;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageCommandOptionBuilder = void 0;
4
+ const discord_js_1 = require("discord.js");
4
5
  /**
5
6
  * Option builder for MessageCommandBuilder
6
7
  */
7
8
  class MessageCommandOptionBuilder {
8
9
  constructor(data) {
9
- this.name = '';
10
- this.description = '';
11
- this.required = false;
12
- this.validator = () => true;
10
+ this._name = '';
11
+ this._description = '';
12
+ this._required = false;
13
13
  if (data?.name !== undefined)
14
14
  this.setName(data.name);
15
15
  if (data?.description !== undefined)
@@ -19,14 +19,38 @@ class MessageCommandOptionBuilder {
19
19
  if (data?.validator !== undefined)
20
20
  this.setValidator(data.validator);
21
21
  }
22
+ get name() {
23
+ return this._name;
24
+ }
25
+ get description() {
26
+ return this._description;
27
+ }
28
+ get required() {
29
+ return this._required;
30
+ }
31
+ get validator() {
32
+ return this._validator;
33
+ }
34
+ set name(name) {
35
+ this.setName(name);
36
+ }
37
+ set description(description) {
38
+ this.setDescription(description);
39
+ }
40
+ set required(required) {
41
+ this.setRequired(required);
42
+ }
43
+ set validator(validator) {
44
+ this.setValidator(validator);
45
+ }
22
46
  /**
23
47
  * Set command option name
24
48
  * @param name Option name
25
49
  */
26
50
  setName(name) {
27
- if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
51
+ if ((0, discord_js_1.isValidationEnabled)() && (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
28
52
  throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
29
- this.name = name;
53
+ this._name = name;
30
54
  return this;
31
55
  }
32
56
  /**
@@ -34,9 +58,9 @@ class MessageCommandOptionBuilder {
34
58
  * @param description Option description
35
59
  */
36
60
  setDescription(description) {
37
- if (!description || typeof description !== 'string')
61
+ if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
38
62
  throw new TypeError('description must be a string.');
39
- this.description = description;
63
+ this._description = description;
40
64
  return this;
41
65
  }
42
66
  /**
@@ -44,9 +68,7 @@ class MessageCommandOptionBuilder {
44
68
  * @param required `true` if this option is required
45
69
  */
46
70
  setRequired(required) {
47
- if (typeof required !== 'boolean')
48
- throw new TypeError('required must be a boolean.');
49
- this.required = required;
71
+ this._required = !!required;
50
72
  return this;
51
73
  }
52
74
  /**
@@ -54,9 +76,9 @@ class MessageCommandOptionBuilder {
54
76
  * @param validator Custom function to validate value given for this option
55
77
  */
56
78
  setValidator(validator) {
57
- if (!validator || typeof validator !== 'function')
79
+ if ((0, discord_js_1.isValidationEnabled)() && validator !== undefined && typeof validator !== 'function')
58
80
  throw new TypeError('validator must be a function.');
59
- this.validator = validator;
81
+ this._validator = validator;
60
82
  return this;
61
83
  }
62
84
  toJSON() {
@@ -11,10 +11,10 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
11
11
  constructor(data) {
12
12
  super();
13
13
  this.type = builders_1.CommandType.SlashCommand;
14
- this.cooldown = 0;
15
- this.requiredBotPermissions = [];
16
- this.requiredMemberPermissions = [];
17
- this.execute = () => {
14
+ this._cooldown = 0;
15
+ this._requiredBotPermissions = [];
16
+ this._requiredMemberPermissions = [];
17
+ this._execute = () => {
18
18
  /* Execute */
19
19
  };
20
20
  // TODO: WTH
@@ -50,27 +50,57 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
50
50
  }
51
51
  }
52
52
  }
53
+ get cooldown() {
54
+ return this._cooldown;
55
+ }
56
+ get requiredBotPermissions() {
57
+ return this._requiredBotPermissions;
58
+ }
59
+ get requiredMemberPermissions() {
60
+ return this._requiredMemberPermissions;
61
+ }
62
+ get halt() {
63
+ return this._halt;
64
+ }
65
+ get execute() {
66
+ return this._execute;
67
+ }
68
+ set cooldown(cooldown) {
69
+ this.setCooldown(cooldown);
70
+ }
71
+ set requiredBotPermissions(permissions) {
72
+ this.setRequiredBotPermissions(permissions);
73
+ }
74
+ set requiredMemberPermissions(permissions) {
75
+ this.setRequiredMemberPermissions(permissions);
76
+ }
77
+ set halt(halt) {
78
+ this.setHalt(halt);
79
+ }
80
+ set execute(execute) {
81
+ this.setExecute(execute);
82
+ }
53
83
  setCooldown(cooldown) {
54
- this.cooldown = cooldown;
84
+ this._cooldown = cooldown;
55
85
  return this;
56
86
  }
57
87
  setRequiredBotPermissions(...permissions) {
58
- this.requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
88
+ this._requiredBotPermissions = (0, discord_js_1.normalizeArray)(permissions);
59
89
  return this;
60
90
  }
61
91
  setRequiredMemberPermissions(...permissions) {
62
- this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
92
+ this._requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
63
93
  this.setDefaultMemberPermissions(this.requiredMemberPermissions.length ? new discord_js_1.PermissionsBitField(this.requiredMemberPermissions).bitfield : undefined);
64
94
  return this;
65
95
  }
66
96
  setHalt(halt) {
67
- this.halt = halt ?? undefined;
97
+ this._halt = halt || undefined;
68
98
  return this;
69
99
  }
70
100
  setExecute(execute) {
71
- if (!execute || typeof execute !== 'function')
101
+ if ((0, discord_js_1.isValidationEnabled)() && (!execute || typeof execute !== 'function'))
72
102
  throw new Error('execute must be a function.');
73
- this.execute = execute;
103
+ this._execute = execute;
74
104
  return this;
75
105
  }
76
106
  setMetadata(metadata) {
@@ -1,5 +1,5 @@
1
- import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandHaltData } from './builders/MessageCommandBuilder';
2
1
  import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
2
+ import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandHaltData } from './builders/MessageCommandBuilder';
3
3
  import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandHaltData } from './builders/SlashCommandBuilder';
4
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
5
5
  import { CommandCooldownManager } from './managers/CommandCooldownManager';
@@ -1,4 +1,4 @@
1
- import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData, MessageCommandOptionResolvable } from '../../types/builders';
2
2
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
3
3
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
4
4
  import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
@@ -67,19 +67,43 @@ export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteF
67
67
  */
68
68
  export declare class MessageCommandBuilder<T = unknown> implements SharedCommandBuilderProperties<T> {
69
69
  readonly type = CommandType.MessageCommand;
70
- name: string;
71
- description: string;
72
- cooldown: number;
73
- aliases: string[];
74
- validateOptions: boolean;
75
- options: MessageCommandOptionBuilder[];
76
- requiredBotPermissions: PermissionResolvable[];
77
- requiredMemberPermissions: PermissionResolvable[];
78
- allowExecuteInDM: boolean;
79
- allowExecuteByBots: boolean;
80
- halt?: MessageCommandHaltFunction<T>;
81
- execute: MessageCommandExecuteFunction<T>;
70
+ private _name;
71
+ private _description;
72
+ private _cooldown;
73
+ private _aliases;
74
+ private _validateOptions;
75
+ private _options;
76
+ private _requiredBotPermissions;
77
+ private _requiredMemberPermissions;
78
+ private _allowExecuteInDM;
79
+ private _allowExecuteByBots;
80
+ private _halt?;
81
+ private _execute;
82
82
  metadata?: T;
83
+ get name(): typeof this._name;
84
+ get description(): typeof this._description;
85
+ get cooldown(): typeof this._cooldown;
86
+ get aliases(): typeof this._aliases;
87
+ get validateOptions(): typeof this._validateOptions;
88
+ get options(): typeof this._options;
89
+ get requiredBotPermissions(): typeof this._requiredBotPermissions;
90
+ get requiredMemberPermissions(): typeof this._requiredMemberPermissions;
91
+ get allowExecuteInDM(): typeof this._allowExecuteInDM;
92
+ get allowExecuteByBots(): typeof this._allowExecuteByBots;
93
+ get halt(): typeof this._halt;
94
+ get execute(): typeof this._execute;
95
+ set name(name: typeof this._name);
96
+ set description(description: typeof this._description);
97
+ set cooldown(cooldown: typeof this._cooldown);
98
+ set aliases(aliases: typeof this._aliases);
99
+ set validateOptions(validate: typeof this._validateOptions);
100
+ set options(options: MessageCommandOptionResolvable[]);
101
+ set requiredBotPermissions(permissions: typeof this._requiredBotPermissions);
102
+ set requiredMemberPermissions(permissions: typeof this._requiredMemberPermissions);
103
+ set allowExecuteInDM(allow: typeof this._allowExecuteInDM);
104
+ set allowExecuteByBots(allow: typeof this._allowExecuteByBots);
105
+ set halt(halt: typeof this._halt);
106
+ set execute(execute: typeof this._execute);
83
107
  constructor(data?: Partial<Omit<MessageCommandData<T>, 'type'>>);
84
108
  /**
85
109
  * Sets the command name
@@ -96,6 +120,11 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
96
120
  * @param aliases Command aliases
97
121
  */
98
122
  addAliases(...aliases: RestOrArray<string>): this;
123
+ /**
124
+ * Replace aliases from command builder
125
+ * @param aliases Command aliases
126
+ */
127
+ setAliases(...aliases: RestOrArray<string>): this;
99
128
  /**
100
129
  * Set if command can be executed in dms
101
130
  * @param allowExecuteInDM `true` if the command can execute in DMs
@@ -107,10 +136,15 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
107
136
  */
108
137
  setAllowExecuteByBots(allowExecuteByBots: boolean): this;
109
138
  /**
110
- * Add option to the command
111
- * @param option Message option builder
139
+ * Add options to command
140
+ * @param options Message options
141
+ */
142
+ addOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
143
+ /**
144
+ * Replace options from command
145
+ * @params options Message options
112
146
  */
113
- addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): this;
147
+ setOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
114
148
  /**
115
149
  * Validate options before executing
116
150
  * @param validateOptions `true` if the command options needs to be validated before executing
@@ -141,10 +175,10 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
141
175
  * @param executeData data to check
142
176
  */
143
177
  static isMessageCommandExecuteData(executeData: unknown): executeData is MessageCommandExecuteData;
178
+ /**
179
+ * Validate message command options
180
+ * @param builder Command builder
181
+ * @param options Parsed command args
182
+ */
183
+ static validateOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
144
184
  }
145
- /**
146
- * Validate message command options
147
- * @param builder Command builder
148
- * @param options Parsed command args
149
- */
150
- export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
@@ -1,13 +1,21 @@
1
- import { MessageCommandOptionData } from '../../types/builders';
1
+ import { MessageCommandOptionData, MessageCommandOptionResolvable } from '../../types/builders';
2
2
  import { Awaitable } from 'discord.js';
3
3
  /**
4
4
  * Option builder for MessageCommandBuilder
5
5
  */
6
6
  export declare class MessageCommandOptionBuilder {
7
- name: string;
8
- description: string;
9
- required: boolean;
10
- validator: (value: string) => Awaitable<boolean>;
7
+ private _name;
8
+ private _description;
9
+ private _required;
10
+ private _validator?;
11
+ get name(): typeof this._name;
12
+ get description(): typeof this._description;
13
+ get required(): typeof this._required;
14
+ get validator(): typeof this._validator;
15
+ set name(name: typeof this._name);
16
+ set description(description: typeof this._description);
17
+ set required(required: typeof this._required);
18
+ set validator(validator: typeof this._validator);
11
19
  constructor(data?: Partial<MessageCommandOptionData>);
12
20
  /**
13
21
  * Set command option name
@@ -28,13 +36,13 @@ export declare class MessageCommandOptionBuilder {
28
36
  * Set your custom function to validate given value for this option
29
37
  * @param validator Custom function to validate value given for this option
30
38
  */
31
- setValidator(validator: (value: string) => Awaitable<boolean>): this;
39
+ setValidator(validator?: (value: string) => Awaitable<boolean>): this;
32
40
  toJSON(): MessageCommandOptionData;
33
41
  /**
34
42
  * Resolves message command option data/builder
35
43
  * @param option Option data to resolve
36
44
  */
37
- static resolveMessageCommandOption(option: MessageCommandOptionBuilder | MessageCommandOptionBuilder): MessageCommandOptionBuilder;
45
+ static resolveMessageCommandOption(option: MessageCommandOptionResolvable): MessageCommandOptionBuilder;
38
46
  /**
39
47
  * Is a Message command option builder
40
48
  * @param builder data to check
@@ -46,12 +46,22 @@ export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandB
46
46
  */
47
47
  export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
48
48
  readonly type = CommandType.SlashCommand;
49
- cooldown: number;
50
- requiredBotPermissions: PermissionResolvable[];
51
- requiredMemberPermissions: PermissionResolvable[];
52
- halt?: SlashCommandHaltFunction<T>;
53
- execute: SlashCommandExecuteFunction<T>;
49
+ private _cooldown;
50
+ private _requiredBotPermissions;
51
+ private _requiredMemberPermissions;
52
+ private _halt?;
53
+ private _execute;
54
54
  metadata?: T;
55
+ get cooldown(): typeof this._cooldown;
56
+ get requiredBotPermissions(): typeof this._requiredBotPermissions;
57
+ get requiredMemberPermissions(): typeof this._requiredMemberPermissions;
58
+ get halt(): typeof this._halt;
59
+ get execute(): typeof this._execute;
60
+ set cooldown(cooldown: typeof this._cooldown);
61
+ set requiredBotPermissions(permissions: typeof this._requiredBotPermissions);
62
+ set requiredMemberPermissions(permissions: typeof this._requiredMemberPermissions);
63
+ set halt(halt: typeof this._halt);
64
+ set execute(execute: typeof this._execute);
55
65
  constructor(data?: Partial<Omit<SlashCommandData<T>, 'type'>>);
56
66
  setCooldown(cooldown: number): this;
57
67
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "6.0.0-dev.20",
3
+ "version": "6.0.0-dev.22",
4
4
  "bin": "./dist/lib/bin.mjs",
5
5
  "license": "GPL-3.0",
6
6
  "type": "commonjs",
@@ -68,8 +68,8 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@discordjs/docgen": "^0.12.1",
71
- "@types/node": "^18.11.0",
72
- "@types/semver": "^7.3.12",
71
+ "@types/node": "^18.11.7",
72
+ "@types/semver": "^7.3.13",
73
73
  "discord.js": "^14.6.0",
74
74
  "prettier": "2.7.1",
75
75
  "rimraf": "^3.0.2",