reciple 3.1.4 → 4.0.0-pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/bin.js CHANGED
@@ -12,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
- var _a, _b;
15
+ var _a, _b, _c;
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const RecipleClient_1 = require("./reciple/classes/RecipleClient");
18
18
  const RecipleConfig_1 = require("./reciple/classes/RecipleConfig");
@@ -26,15 +26,15 @@ if (flags_1.flags.version) {
26
26
  console.log(`v${version_1.version}`);
27
27
  process.exit(0);
28
28
  }
29
- const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json', 'modules.yml', '.rmmcache'];
30
- if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
31
- const ask = (_a = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _a !== void 0 ? _a : '';
29
+ const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
30
+ if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)((_a = flags_1.flags.config) !== null && _a !== void 0 ? _a : './reciple.yml')) {
31
+ const ask = (_b = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _b !== void 0 ? _b : '';
32
32
  if (ask.toString().toLowerCase() !== 'y')
33
33
  process.exit(0);
34
34
  }
35
35
  let configParser;
36
36
  try {
37
- configParser = new RecipleConfig_1.RecipleConfig((_b = flags_1.flags.config) !== null && _b !== void 0 ? _b : './reciple.yml').parseConfig();
37
+ configParser = new RecipleConfig_1.RecipleConfig((_c = flags_1.flags.config) !== null && _c !== void 0 ? _c : './reciple.yml').parseConfig();
38
38
  }
39
39
  catch (err) {
40
40
  console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
@@ -47,9 +47,9 @@ if (config.fileLogging.clientLogs)
47
47
  (() => __awaiter(void 0, void 0, void 0, function* () {
48
48
  yield client.startModules();
49
49
  client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
50
- var _c;
50
+ var _d;
51
51
  if (client.isClientLogsEnabled())
52
- client.logger.warn(`Logged in as ${((_c = client.user) === null || _c === void 0 ? void 0 : _c.tag) || 'Unknown'}!`);
52
+ client.logger.warn(`Logged in as ${((_d = client.user) === null || _d === void 0 ? void 0 : _d.tag) || 'Unknown'}!`);
53
53
  yield client.loadModules();
54
54
  client.addCommandListeners();
55
55
  }));
package/bin/index.d.ts CHANGED
@@ -2,9 +2,9 @@ export * from './reciple/classes/CommandCooldownManager';
2
2
  export * from './reciple/classes/MessageCommandOptionManager';
3
3
  export * from './reciple/classes/RecipleClient';
4
4
  export * from './reciple/classes/RecipleConfig';
5
- export * from './reciple/classes/builders/InteractionCommandBuilder';
6
5
  export * from './reciple/classes/builders/MessageCommandBuilder';
7
6
  export * from './reciple/classes/builders/MessageCommandOptionBuilder';
7
+ export * from './reciple/classes/builders/SlashCommandBuilder';
8
8
  export * from './reciple/types/builders';
9
9
  export * from './reciple/types/commands';
10
10
  export * from './reciple/types/paramOptions';
package/bin/index.js CHANGED
@@ -18,9 +18,9 @@ __exportStar(require("./reciple/classes/CommandCooldownManager"), exports);
18
18
  __exportStar(require("./reciple/classes/MessageCommandOptionManager"), exports);
19
19
  __exportStar(require("./reciple/classes/RecipleClient"), exports);
20
20
  __exportStar(require("./reciple/classes/RecipleConfig"), exports);
21
- __exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
22
21
  __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
23
22
  __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
23
+ __exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
24
24
  __exportStar(require("./reciple/types/builders"), exports);
25
25
  __exportStar(require("./reciple/types/commands"), exports);
26
26
  __exportStar(require("./reciple/types/paramOptions"), exports);
@@ -1,4 +1,4 @@
1
- import { RecipleCommandBuilderType } from '../types/builders';
1
+ import { CommandBuilderType } from '../types/builders';
2
2
  import { Guild, TextBasedChannel, User } from 'discord.js';
3
3
  /**
4
4
  * Object interface for cooled-down user
@@ -6,7 +6,7 @@ import { Guild, TextBasedChannel, User } from 'discord.js';
6
6
  export interface CooledDownUser {
7
7
  user: User;
8
8
  command: string;
9
- type: RecipleCommandBuilderType;
9
+ type: CommandBuilderType;
10
10
  guild?: Guild | null;
11
11
  channel?: TextBasedChannel;
12
12
  expireTime: number;
@@ -6,7 +6,7 @@ export declare class MessageCommandOptionManager extends Array<MessageCommandVal
6
6
  /**
7
7
  * @param options Validated options
8
8
  */
9
- constructor(options: MessageCommandValidatedOption[]);
9
+ constructor(...options: MessageCommandValidatedOption[]);
10
10
  /**
11
11
  * Get the option info
12
12
  * @param name Option name
@@ -8,9 +8,8 @@ class MessageCommandOptionManager extends Array {
8
8
  /**
9
9
  * @param options Validated options
10
10
  */
11
- constructor(options) {
12
- super();
13
- this.push(...options);
11
+ constructor(...options) {
12
+ super(...(options !== null && options !== void 0 ? options : []));
14
13
  }
15
14
  get(name, required) {
16
15
  const option = this.find(o => o.name == name);
@@ -1,9 +1,9 @@
1
1
  import { RecipleModule } from '../modules';
2
2
  import { ApplicationCommandBuilder } from '../registerInteractionCommands';
3
- import { RecipleCommandBuilder, RecipleCommandBuilderType } from '../types/builders';
4
- import { RecipleAddModuleOptions } from '../types/paramOptions';
5
- import { InteractionCommandBuilder, InteractionCommandExecuteData } from './builders/InteractionCommandBuilder';
3
+ import { CommandBuilder, CommandBuilderType } from '../types/builders';
4
+ import { RecipleClientAddModuleOptions } from '../types/paramOptions';
6
5
  import { MessageCommandBuilder, MessageCommandExecuteData } from './builders/MessageCommandBuilder';
6
+ import { SlashCommandBuilder, SlashCommandExecuteData } from './builders/SlashCommandBuilder';
7
7
  import { CommandCooldownManager } from './CommandCooldownManager';
8
8
  import { Config } from './RecipleConfig';
9
9
  import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
@@ -21,8 +21,8 @@ export interface RecipleClientCommands {
21
21
  messageCommands: {
22
22
  [commandName: string]: MessageCommandBuilder;
23
23
  };
24
- interactionCommands: {
25
- [commandName: string]: InteractionCommandBuilder;
24
+ slashCommands: {
25
+ [commandName: string]: SlashCommandBuilder;
26
26
  };
27
27
  }
28
28
  /**
@@ -30,7 +30,7 @@ export interface RecipleClientCommands {
30
30
  */
31
31
  export interface RecipleClientEvents extends ClientEvents {
32
32
  recipleMessageCommandCreate: [executeData: MessageCommandExecuteData];
33
- recipleInteractionCommandCreate: [executeData: InteractionCommandExecuteData];
33
+ recipleInteractionCommandCreate: [executeData: SlashCommandExecuteData];
34
34
  recipleReplyError: [error: unknown];
35
35
  }
36
36
  /**
@@ -49,6 +49,9 @@ export interface RecipleClient<Ready extends boolean = boolean> extends Client<R
49
49
  removeAllListeners(event?: string | symbol): this;
50
50
  isReady(): this is RecipleClient<true>;
51
51
  }
52
+ /**
53
+ * The reciple client
54
+ */
52
55
  export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
53
56
  config: Config;
54
57
  commands: RecipleClientCommands;
@@ -67,19 +70,19 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
67
70
  */
68
71
  startModules(folder?: string): Promise<RecipleClient<Ready>>;
69
72
  /**
70
- * Execute `onLoad()` from client modules and register interaction commands if enabled
73
+ * Execute `onLoad()` from client modules and register application commands if enabled
71
74
  */
72
75
  loadModules(): Promise<RecipleClient<Ready>>;
73
76
  /**
74
77
  * Add module
75
78
  * @param options Module options
76
79
  */
77
- addModule(options: RecipleAddModuleOptions): Promise<void>;
80
+ addModule(options: RecipleClientAddModuleOptions): Promise<void>;
78
81
  /**
79
- * Add interaction or message command to client
80
- * @param command Interaction/Message command builder
82
+ * Add slash or message command to client
83
+ * @param command Slash/Message command builder
81
84
  */
82
- addCommand(command: RecipleCommandBuilder): RecipleClient<Ready>;
85
+ addCommand(command: CommandBuilder): RecipleClient<Ready>;
83
86
  /**
84
87
  * Listed to command executions
85
88
  */
@@ -91,10 +94,10 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
91
94
  */
92
95
  messageCommandExecute(message: Message, prefix?: string): Promise<void | MessageCommandExecuteData>;
93
96
  /**
94
- * Execute an Interaction command
95
- * @param interaction Command Interaction
97
+ * Execute a slash command
98
+ * @param interaction Slash command interaction
96
99
  */
97
- interactionCommandExecute(interaction: Interaction | ChatInputCommandInteraction): Promise<void | InteractionCommandExecuteData>;
100
+ slashCommandExecute(interaction: Interaction | ChatInputCommandInteraction): Promise<void | SlashCommandExecuteData>;
98
101
  /**
99
102
  * Get a message from config
100
103
  * @param messageKey Config messages key
@@ -106,8 +109,8 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
106
109
  * @param command Command name
107
110
  * @param type Command type
108
111
  */
109
- findCommand(command: string, type: RecipleCommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
110
- findCommand(command: string, type: RecipleCommandBuilderType.InteractionCommand): InteractionCommandBuilder | undefined;
112
+ findCommand(command: string, type: CommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
113
+ findCommand(command: string, type: CommandBuilderType.SlashCommand): SlashCommandBuilder | undefined;
111
114
  /**
112
115
  * Returns true if client logs is enabled
113
116
  */
@@ -126,7 +129,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
126
129
  /**
127
130
  * Error message when a command fails to execute
128
131
  * @param err Received error
129
- * @param command Interaction/Message command execute data
132
+ * @param command Slash/Message command execute data
130
133
  */
131
134
  private _commandExecuteError;
132
135
  }
@@ -24,6 +24,9 @@ const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
24
24
  const RecipleConfig_1 = require("./RecipleConfig");
25
25
  const discord_js_1 = require("discord.js");
26
26
  const fallout_utility_1 = require("fallout-utility");
27
+ /**
28
+ * The reciple client
29
+ */
27
30
  class RecipleClient extends discord_js_1.Client {
28
31
  /**
29
32
  * @param options Client options
@@ -32,7 +35,7 @@ class RecipleClient extends discord_js_1.Client {
32
35
  var _a, _b, _c;
33
36
  super(options);
34
37
  this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
35
- this.commands = { messageCommands: {}, interactionCommands: {} };
38
+ this.commands = { messageCommands: {}, slashCommands: {} };
36
39
  this.otherApplicationCommandData = [];
37
40
  this.commandCooldowns = new CommandCooldownManager_1.CommandCooldownManager();
38
41
  this.modules = [];
@@ -60,7 +63,7 @@ class RecipleClient extends discord_js_1.Client {
60
63
  });
61
64
  }
62
65
  /**
63
- * Execute `onLoad()` from client modules and register interaction commands if enabled
66
+ * Execute `onLoad()` from client modules and register application commands if enabled
64
67
  */
65
68
  loadModules() {
66
69
  var _a, _b;
@@ -86,13 +89,13 @@ class RecipleClient extends discord_js_1.Client {
86
89
  if (this.isClientLogsEnabled()) {
87
90
  this.logger.info(`${this.modules.length} modules loaded.`);
88
91
  this.logger.info(`${Object.keys(this.commands.messageCommands).length} message commands loaded.`);
89
- this.logger.info(`${Object.keys(this.commands.interactionCommands).length} interaction commands loaded.`);
92
+ this.logger.info(`${Object.keys(this.commands.slashCommands).length} slash commands loaded.`);
90
93
  }
91
- if (this.config.commands.interactionCommand.registerCommands) {
92
- yield (0, registerInteractionCommands_1.registerInteractionCommands)({
94
+ if (this.config.commands.slashCommand.registerCommands) {
95
+ yield (0, registerInteractionCommands_1.registerApplicationCommands)({
93
96
  client: this,
94
- commands: [...Object.values(this.commands.interactionCommands), ...this.otherApplicationCommandData],
95
- guilds: this.config.commands.interactionCommand.guilds
97
+ commands: [...Object.values(this.commands.slashCommands), ...this.otherApplicationCommandData],
98
+ guilds: this.config.commands.slashCommand.guilds
96
99
  });
97
100
  }
98
101
  return this;
@@ -106,7 +109,7 @@ class RecipleClient extends discord_js_1.Client {
106
109
  var _a;
107
110
  return __awaiter(this, void 0, void 0, function* () {
108
111
  const { script } = options;
109
- const registerCommands = options.registerInteractionCommands;
112
+ const registerCommands = options.registerApplicationCommands;
110
113
  const info = options.moduleInfo;
111
114
  this.modules.push({
112
115
  script,
@@ -122,24 +125,24 @@ class RecipleClient extends discord_js_1.Client {
122
125
  this.addCommand(command);
123
126
  }
124
127
  if (registerCommands)
125
- yield (0, registerInteractionCommands_1.registerInteractionCommands)({
128
+ yield (0, registerInteractionCommands_1.registerApplicationCommands)({
126
129
  client: this,
127
- commands: [...Object.values(this.commands.interactionCommands), ...this.otherApplicationCommandData],
128
- guilds: this.config.commands.interactionCommand.guilds
130
+ commands: [...Object.values(this.commands.slashCommands), ...this.otherApplicationCommandData],
131
+ guilds: this.config.commands.slashCommand.guilds
129
132
  });
130
133
  });
131
134
  }
132
135
  /**
133
- * Add interaction or message command to client
134
- * @param command Interaction/Message command builder
136
+ * Add slash or message command to client
137
+ * @param command Slash/Message command builder
135
138
  */
136
139
  addCommand(command) {
137
140
  var _a;
138
- if (command.builder === builders_1.RecipleCommandBuilderType.MessageCommand) {
141
+ if (command.builder === builders_1.CommandBuilderType.MessageCommand) {
139
142
  this.commands.messageCommands[command.name] = command;
140
143
  }
141
- else if (command.builder === builders_1.RecipleCommandBuilderType.InteractionCommand) {
142
- this.commands.interactionCommands[command.name] = command;
144
+ else if (command.builder === builders_1.CommandBuilderType.SlashCommand) {
145
+ this.commands.slashCommands[command.name] = command;
143
146
  }
144
147
  else if (this.isClientLogsEnabled()) {
145
148
  this.logger.error(`Unknow command "${(_a = typeof command) !== null && _a !== void 0 ? _a : 'unknown'}".`);
@@ -152,8 +155,8 @@ class RecipleClient extends discord_js_1.Client {
152
155
  addCommandListeners() {
153
156
  if (this.config.commands.messageCommand.enabled)
154
157
  this.on('messageCreate', (message) => { this.messageCommandExecute(message); });
155
- if (this.config.commands.interactionCommand.enabled)
156
- this.on('interactionCreate', (interaction) => { this.interactionCommandExecute(interaction); });
158
+ if (this.config.commands.slashCommand.enabled)
159
+ this.on('interactionCreate', (interaction) => { this.slashCommandExecute(interaction); });
157
160
  return this;
158
161
  }
159
162
  /**
@@ -169,7 +172,7 @@ class RecipleClient extends discord_js_1.Client {
169
172
  const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.commands.messageCommand.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
170
173
  if (!parseCommand || !(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command))
171
174
  return;
172
- const command = this.findCommand(parseCommand.command, builders_1.RecipleCommandBuilderType.MessageCommand);
175
+ const command = this.findCommand(parseCommand.command, builders_1.CommandBuilderType.MessageCommand);
173
176
  if (!command)
174
177
  return;
175
178
  const commandOptions = (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
@@ -192,20 +195,20 @@ class RecipleClient extends discord_js_1.Client {
192
195
  return;
193
196
  if (command.validateOptions) {
194
197
  if (commandOptions.some(o => o.invalid)) {
195
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.invalid)) }))) {
198
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.invalid)) }))) {
196
199
  message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this._replyError(er));
197
200
  }
198
201
  return;
199
202
  }
200
203
  if (commandOptions.some(o => o.missing)) {
201
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.missing)) }))) {
204
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.missing)) }))) {
202
205
  message.reply(this.getMessage('missingArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
203
206
  }
204
207
  return;
205
208
  }
206
209
  }
207
210
  if (message.guild && !(0, permissions_1.botHasExecutePermissions)(message.guild, command.requiredBotPermissions)) {
208
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.MissingBotPermissions }))) {
211
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingBotPermissions }))) {
209
212
  message.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
210
213
  }
211
214
  return;
@@ -215,13 +218,13 @@ class RecipleClient extends discord_js_1.Client {
215
218
  command: command.name,
216
219
  channel: message.channel,
217
220
  guild: message.guild,
218
- type: builders_1.RecipleCommandBuilderType.MessageCommand
221
+ type: builders_1.CommandBuilderType.MessageCommand
219
222
  };
220
223
  if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
221
224
  this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
222
225
  }
223
226
  else if (this.config.commands.messageCommand.enableCooldown && command.cooldown) {
224
- if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.RecipleHaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
227
+ if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.HaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
225
228
  yield message.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
226
229
  }
227
230
  return;
@@ -229,46 +232,46 @@ class RecipleClient extends discord_js_1.Client {
229
232
  try {
230
233
  yield Promise.resolve(command.execute(executeData))
231
234
  .then(() => this.emit('recipleMessageCommandCreate', executeData))
232
- .catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
235
+ .catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
233
236
  return executeData;
234
237
  }
235
238
  catch (err) {
236
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err }))) {
239
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err }))) {
237
240
  this._commandExecuteError(err, executeData);
238
241
  }
239
242
  }
240
243
  }
241
- else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.MissingMemberPermissions }))) {
244
+ else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingMemberPermissions }))) {
242
245
  message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
243
246
  }
244
247
  });
245
248
  }
246
249
  /**
247
- * Execute an Interaction command
248
- * @param interaction Command Interaction
250
+ * Execute a slash command
251
+ * @param interaction Slash command interaction
249
252
  */
250
- interactionCommandExecute(interaction) {
253
+ slashCommandExecute(interaction) {
251
254
  var _a, _b;
252
255
  return __awaiter(this, void 0, void 0, function* () {
253
256
  if (!interaction || interaction.type !== discord_js_1.InteractionType.ApplicationCommand || !interaction.isChatInputCommand() || !this.isReady())
254
257
  return;
255
- const command = this.findCommand(interaction.commandName, builders_1.RecipleCommandBuilderType.InteractionCommand);
258
+ const command = this.findCommand(interaction.commandName, builders_1.CommandBuilderType.SlashCommand);
256
259
  if (!command)
257
260
  return;
258
261
  const executeData = {
259
- interaction: interaction,
262
+ interaction,
260
263
  builder: command,
261
264
  client: this
262
265
  };
263
266
  if ((0, permissions_1.userHasCommandPermissions)({
264
267
  builder: command,
265
268
  memberPermissions: (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined,
266
- commandPermissions: this.config.commands.interactionCommand.permissions
269
+ commandPermissions: this.config.commands.slashCommand.permissions
267
270
  })) {
268
271
  if (!command || (0, permissions_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
269
272
  return;
270
273
  if (interaction.guild && !(0, permissions_1.botHasExecutePermissions)(interaction.guild, command.requiredBotPermissions)) {
271
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.MissingBotPermissions }))) {
274
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingBotPermissions }))) {
272
275
  yield interaction.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
273
276
  }
274
277
  return;
@@ -278,13 +281,13 @@ class RecipleClient extends discord_js_1.Client {
278
281
  command: command.name,
279
282
  channel: (_b = interaction.channel) !== null && _b !== void 0 ? _b : undefined,
280
283
  guild: interaction.guild,
281
- type: builders_1.RecipleCommandBuilderType.InteractionCommand
284
+ type: builders_1.CommandBuilderType.SlashCommand
282
285
  };
283
- if (this.config.commands.interactionCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
286
+ if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
284
287
  this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
285
288
  }
286
- else if (this.config.commands.interactionCommand.enableCooldown && command.cooldown) {
287
- if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.RecipleHaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
289
+ else if (this.config.commands.slashCommand.enableCooldown && command.cooldown) {
290
+ if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.HaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
288
291
  yield interaction.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
289
292
  }
290
293
  return;
@@ -292,16 +295,16 @@ class RecipleClient extends discord_js_1.Client {
292
295
  try {
293
296
  yield Promise.resolve(command.execute(executeData))
294
297
  .then(() => this.emit('recipleInteractionCommandCreate', executeData))
295
- .catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
298
+ .catch((err) => __awaiter(this, void 0, void 0, function* () { return (yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
296
299
  return executeData;
297
300
  }
298
301
  catch (err) {
299
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err }))) {
302
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.Error, error: err }))) {
300
303
  this._commandExecuteError(err, executeData);
301
304
  }
302
305
  }
303
306
  }
304
- else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.RecipleHaltedCommandReason.MissingMemberPermissions }))) {
307
+ else if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingMemberPermissions }))) {
305
308
  yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
306
309
  }
307
310
  });
@@ -318,9 +321,9 @@ class RecipleClient extends discord_js_1.Client {
318
321
  findCommand(command, type) {
319
322
  var _a;
320
323
  switch (type) {
321
- case builders_1.RecipleCommandBuilderType.InteractionCommand:
322
- return this.commands.interactionCommands[command];
323
- case builders_1.RecipleCommandBuilderType.MessageCommand:
324
+ case builders_1.CommandBuilderType.SlashCommand:
325
+ return this.commands.slashCommands[command];
326
+ case builders_1.CommandBuilderType.MessageCommand:
324
327
  return (_a = this.commands.messageCommands[command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
325
328
  ? Object.values(this.commands.messageCommands).find(c => c.aliases.some(a => a == (command === null || command === void 0 ? void 0 : command.toLowerCase())))
326
329
  : undefined);
@@ -346,7 +349,7 @@ class RecipleClient extends discord_js_1.Client {
346
349
  return __awaiter(this, void 0, void 0, function* () {
347
350
  try {
348
351
  return (_a = (command.halt
349
- ? yield (command.builder == builders_1.RecipleCommandBuilderType.InteractionCommand
352
+ ? yield (command.builder == builders_1.CommandBuilderType.SlashCommand
350
353
  ? Promise.resolve(command.halt(haltData))
351
354
  : Promise.resolve(command.halt(haltData))).catch(err => { throw err; })
352
355
  : false)) !== null && _a !== void 0 ? _a : false;
@@ -363,12 +366,12 @@ class RecipleClient extends discord_js_1.Client {
363
366
  /**
364
367
  * Error message when a command fails to execute
365
368
  * @param err Received error
366
- * @param command Interaction/Message command execute data
369
+ * @param command Slash/Message command execute data
367
370
  */
368
371
  _commandExecuteError(err, command) {
369
372
  return __awaiter(this, void 0, void 0, function* () {
370
373
  if (this.isClientLogsEnabled()) {
371
- this.logger.error(`An error occured executing ${command.builder.builder == builders_1.RecipleCommandBuilderType.MessageCommand ? 'message' : 'interaction'} command "${command.builder.name}"`);
374
+ this.logger.error(`An error occured executing ${command.builder.builder == builders_1.CommandBuilderType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
372
375
  this.logger.error(err);
373
376
  }
374
377
  if (!err || !command)
@@ -379,7 +382,7 @@ class RecipleClient extends discord_js_1.Client {
379
382
  yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch(er => this._replyError(er));
380
383
  }
381
384
  else if (command === null || command === void 0 ? void 0 : command.interaction) {
382
- if (!this.config.commands.interactionCommand.replyOnError)
385
+ if (!this.config.commands.slashCommand.replyOnError)
383
386
  return;
384
387
  yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch(er => this._replyError(er));
385
388
  }
@@ -24,7 +24,7 @@ export interface Config {
24
24
  commands: ConfigCommandPermissions[];
25
25
  };
26
26
  };
27
- interactionCommand: {
27
+ slashCommand: {
28
28
  enabled: boolean;
29
29
  replyOnError: boolean;
30
30
  registerCommands: boolean;
@@ -55,6 +55,7 @@ export interface Config {
55
55
  };
56
56
  ignoredFiles: string[];
57
57
  modulesFolder: string;
58
+ disableVersionCheck: boolean;
58
59
  version: string;
59
60
  }
60
61
  /**
@@ -1,5 +1,5 @@
1
- import { RecipleCommandBuilderType } from '../../types/builders';
2
- import { RecipleHaltedCommandData } from '../../types/commands';
1
+ import { CommandBuilderType } from '../../types/builders';
2
+ import { HaltedCommandData } from '../../types/commands';
3
3
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
4
4
  import { RecipleClient } from '../RecipleClient';
5
5
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
@@ -29,7 +29,7 @@ export interface MessageCommandValidatedOption {
29
29
  * Reciple builder for message command
30
30
  */
31
31
  export declare class MessageCommandBuilder {
32
- readonly builder = RecipleCommandBuilderType.MessageCommand;
32
+ readonly builder = CommandBuilderType.MessageCommand;
33
33
  name: string;
34
34
  cooldown: number;
35
35
  description: string;
@@ -40,7 +40,7 @@ export declare class MessageCommandBuilder {
40
40
  requiredMemberPermissions: PermissionResolvable[];
41
41
  allowExecuteInDM: boolean;
42
42
  allowExecuteByBots: boolean;
43
- halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
43
+ halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
44
44
  execute: (executeData: MessageCommandExecuteData) => void;
45
45
  /**
46
46
  * Sets the command name
@@ -87,7 +87,7 @@ export declare class MessageCommandBuilder {
87
87
  * Function when the command is interupted
88
88
  * @param halt Function to execute when command is halted
89
89
  */
90
- setHalt(halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
90
+ setHalt(halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
91
91
  /**
92
92
  * Function when the command is executed
93
93
  * @param execute Function to execute when the command is called
@@ -103,11 +103,5 @@ export declare class MessageCommandBuilder {
103
103
  * @param validateOptions `true` if the command options needs to be validated before executing
104
104
  */
105
105
  setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
106
- /**
107
- * validate given command options
108
- * @deprecated use `validateMessageCommandOptions()` instead
109
- * @param options Parsed message command data
110
- */
111
- getCommandOptionValues(options: CommandMessage): MessageCommandOptionManager;
112
106
  }
113
107
  export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): MessageCommandOptionManager;
@@ -9,7 +9,7 @@ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
9
9
  */
10
10
  class MessageCommandBuilder {
11
11
  constructor() {
12
- this.builder = builders_1.RecipleCommandBuilderType.MessageCommand;
12
+ this.builder = builders_1.CommandBuilderType.MessageCommand;
13
13
  this.name = '';
14
14
  this.cooldown = 0;
15
15
  this.description = '';
@@ -144,15 +144,6 @@ class MessageCommandBuilder {
144
144
  this.validateOptions = validateOptions;
145
145
  return this;
146
146
  }
147
- /**
148
- * validate given command options
149
- * @deprecated use `validateMessageCommandOptions()` instead
150
- * @param options Parsed message command data
151
- */
152
- // TODO: Remove this on the next major update
153
- getCommandOptionValues(options) {
154
- return validateMessageCommandOptions(this, options);
155
- }
156
147
  }
157
148
  exports.MessageCommandBuilder = MessageCommandBuilder;
158
149
  function validateMessageCommandOptions(builder, options) {
@@ -186,6 +177,6 @@ function validateMessageCommandOptions(builder, options) {
186
177
  result.push(value);
187
178
  i++;
188
179
  }
189
- return new MessageCommandOptionManager_1.MessageCommandOptionManager(result);
180
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
190
181
  }
191
182
  exports.validateMessageCommandOptions = validateMessageCommandOptions;
@@ -0,0 +1,56 @@
1
+ import { CommandBuilderType } from '../../types/builders';
2
+ import { HaltedCommandData } from '../../types/commands';
3
+ import { RecipleClient } from '../RecipleClient';
4
+ import { Awaitable, ChatInputCommandInteraction, PermissionResolvable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
5
+ /**
6
+ * Execute data for interaction command
7
+ */
8
+ export interface SlashCommandExecuteData {
9
+ interaction: ChatInputCommandInteraction;
10
+ builder: SlashCommandBuilder;
11
+ client: RecipleClient<true>;
12
+ }
13
+ export interface SlashCommandSubcommandsOnlyBuilder extends DiscordJsSlashCommandSubcommandsOnlyBuilder, Pick<SlashCommandBuilder, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute"> {
14
+ }
15
+ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
16
+ addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
17
+ addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
18
+ }
19
+ /**
20
+ * Reciple builder for interaction/slash command
21
+ */
22
+ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
23
+ readonly builder = CommandBuilderType.SlashCommand;
24
+ cooldown: number;
25
+ requiredBotPermissions: PermissionResolvable[];
26
+ requiredMemberPermissions: PermissionResolvable[];
27
+ allowExecuteInDM: boolean;
28
+ halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>;
29
+ execute: (executeData: SlashCommandExecuteData) => Awaitable<void>;
30
+ /**
31
+ * Sets the execute cooldown for this command.
32
+ * - `0` means no cooldown
33
+ * @param cooldown Command cooldown in milliseconds
34
+ */
35
+ setCooldown(cooldown: number): SlashCommandBuilder;
36
+ /**
37
+ * Set required bot permissions to execute the command
38
+ * @param permissions Bot's required permissions
39
+ */
40
+ setRequiredBotPermissions(...permissions: PermissionResolvable[]): SlashCommandBuilder;
41
+ /**
42
+ * Set required permissions to execute the command
43
+ * @param permissions User's return permissions
44
+ */
45
+ setRequiredMemberPermissions(...permissions: PermissionResolvable[]): SlashCommandBuilder;
46
+ /**
47
+ * Function when the command is interupted
48
+ * @param halt Function to execute when command is halted
49
+ */
50
+ setHalt(halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>): SlashCommandBuilder;
51
+ /**
52
+ * Function when the command is executed
53
+ * @param execute Function to execute when the command is called
54
+ */
55
+ setExecute(execute: (executeData: SlashCommandExecuteData) => void): SlashCommandBuilder;
56
+ }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InteractionCommandBuilder = void 0;
3
+ exports.SlashCommandBuilder = void 0;
4
4
  const builders_1 = require("../../types/builders");
5
5
  const discord_js_1 = require("discord.js");
6
6
  /**
7
7
  * Reciple builder for interaction/slash command
8
8
  */
9
- class InteractionCommandBuilder extends discord_js_1.SlashCommandBuilder {
9
+ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
10
10
  constructor() {
11
11
  super(...arguments);
12
- this.builder = builders_1.RecipleCommandBuilderType.InteractionCommand;
12
+ this.builder = builders_1.CommandBuilderType.SlashCommand;
13
13
  this.cooldown = 0;
14
14
  this.requiredBotPermissions = [];
15
15
  this.requiredMemberPermissions = [];
@@ -60,4 +60,4 @@ class InteractionCommandBuilder extends discord_js_1.SlashCommandBuilder {
60
60
  return this;
61
61
  }
62
62
  }
63
- exports.InteractionCommandBuilder = InteractionCommandBuilder;
63
+ exports.SlashCommandBuilder = SlashCommandBuilder;
@@ -6,11 +6,3 @@ import { Logger } from 'fallout-utility';
6
6
  * @param colorizeMessage add logger colours to messages
7
7
  */
8
8
  export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
9
- /**
10
- * Create new logger
11
- * @deprecated Use `createLogger` instead
12
- * @param stringifyJSON stringify json objects in console
13
- * @param debugmode display debug messages
14
- * @param colorizeMessage add logger colours to messages
15
- */
16
- export declare function logger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logger = exports.createLogger = void 0;
6
+ exports.createLogger = void 0;
7
7
  const flags_1 = require("./flags");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const fallout_utility_1 = require("fallout-utility");
@@ -34,16 +34,3 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
34
34
  });
35
35
  }
36
36
  exports.createLogger = createLogger;
37
- /**
38
- * Create new logger
39
- * @deprecated Use `createLogger` instead
40
- * @param stringifyJSON stringify json objects in console
41
- * @param debugmode display debug messages
42
- * @param colorizeMessage add logger colours to messages
43
- */
44
- // TODO: Remove this on next major release
45
- function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
46
- process.emitWarning('logger() is deprecated use createLogger() instead', 'DeprecationWarning');
47
- return createLogger(stringifyJSON, debugmode, colorizeMessage);
48
- }
49
- exports.logger = logger;
@@ -1,15 +1,15 @@
1
1
  import { RecipleClient } from './classes/RecipleClient';
2
- import { RecipleCommandBuilder } from './types/builders';
2
+ import { CommandBuilder } from './types/builders';
3
3
  export declare type LoadedModules = {
4
- commands: RecipleCommandBuilder[];
4
+ commands: CommandBuilder[];
5
5
  modules: RecipleModule[];
6
6
  };
7
7
  /**
8
8
  * Reciple script object interface
9
9
  */
10
- export declare class RecipleScript {
10
+ export interface RecipleScript {
11
11
  versions: string | string[];
12
- commands?: RecipleCommandBuilder[];
12
+ commands?: CommandBuilder[];
13
13
  onLoad?(reciple: RecipleClient): void | Promise<void>;
14
14
  onStart(reciple: RecipleClient): boolean | Promise<boolean>;
15
15
  }
@@ -44,13 +44,13 @@ function loadModules(client, folder) {
44
44
  if (!((_a = module_.versions) === null || _a === void 0 ? void 0 : _a.length))
45
45
  throw new Error('Module does not have supported versions.');
46
46
  const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
47
- if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
47
+ if (!client.config.disableVersionCheck && !versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
48
48
  throw new Error((_b = 'Module versions is not defined or unsupported; supported versions: ' + module_.versions) !== null && _b !== void 0 ? _b : 'none' + '; current version: ' + version_1.version);
49
49
  if (!(yield Promise.resolve(module_.onStart(client))))
50
50
  throw new Error(script + ' onStart is not defined or returned false.');
51
51
  if (module_.commands) {
52
52
  for (const command of module_.commands) {
53
- if (command.builder === builders_1.RecipleCommandBuilderType.MessageCommand || command.builder === builders_1.RecipleCommandBuilderType.InteractionCommand) {
53
+ if (command.builder === builders_1.CommandBuilderType.MessageCommand || command.builder === builders_1.CommandBuilderType.SlashCommand) {
54
54
  commands.push(command);
55
55
  }
56
56
  }
@@ -69,7 +69,7 @@ function loadModules(client, folder) {
69
69
  client.logger.error(`A ${c.builder} command name is not defined in ${script}`);
70
70
  return false;
71
71
  }
72
- if (c.builder === builders_1.RecipleCommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
72
+ if (c.builder === builders_1.CommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
73
73
  if (client.isClientLogsEnabled())
74
74
  client.logger.error(`A ${c.builder} option name is not defined in ${script}`);
75
75
  return false;
@@ -1,11 +1,11 @@
1
1
  import { Config } from './classes/RecipleConfig';
2
- import { RecipleUserHasCommandPermissionsOptions } from './types/paramOptions';
2
+ import { UserHasCommandPermissionsOptions } from './types/paramOptions';
3
3
  import { Guild, PermissionResolvable } from 'discord.js';
4
4
  /**
5
5
  * Check if the user has permissions to execute the given command name
6
6
  * @param options options
7
7
  */
8
- export declare function userHasCommandPermissions(options: RecipleUserHasCommandPermissionsOptions): boolean;
8
+ export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
9
9
  /**
10
10
  * Check if the bot has the required permissions in a guild
11
11
  * @param guild Guild
@@ -1,9 +1,9 @@
1
- import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
2
- import { RecipleRegisterInteractionCommandsOptions } from './types/paramOptions';
3
- import { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
4
- export declare type ApplicationCommandBuilder = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder;
1
+ import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder';
2
+ import { RegisterApplicationCommandsOptions } from './types/paramOptions';
3
+ import { ContextMenuCommandBuilder, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
4
+ export declare type ApplicationCommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
5
  /**
6
- * Register interaction commands
7
- * @param options Register interaction commands options
6
+ * Register application commands
7
+ * @param options Register application commands options
8
8
  */
9
- export declare function registerInteractionCommands(options: RecipleRegisterInteractionCommandsOptions): Promise<void>;
9
+ export declare function registerApplicationCommands(options: RegisterApplicationCommandsOptions): Promise<void>;
@@ -9,31 +9,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.registerInteractionCommands = void 0;
13
- const InteractionCommandBuilder_1 = require("./classes/builders/InteractionCommandBuilder");
12
+ exports.registerApplicationCommands = void 0;
13
+ const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
14
14
  /**
15
- * Register interaction commands
16
- * @param options Register interaction commands options
15
+ * Register application commands
16
+ * @param options Register application commands options
17
17
  */
18
- function registerInteractionCommands(options) {
18
+ function registerApplicationCommands(options) {
19
19
  var _a, _b, _c, _d;
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  const client = options.client;
22
22
  const guilds = typeof options.guilds == 'string' ? [options.guilds] : options.guilds;
23
- const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.interactionCommands).map(cmd => {
23
+ const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.slashCommands).map(cmd => {
24
24
  var _a;
25
25
  if (typeof (cmd === null || cmd === void 0 ? void 0 : cmd.toJSON) == 'undefined')
26
26
  return cmd;
27
27
  cmd = cmd;
28
- if (cmd instanceof InteractionCommandBuilder_1.InteractionCommandBuilder && client.config.commands.interactionCommand.setRequiredPermissions) {
29
- const permissions = client.config.commands.interactionCommand.permissions.enabled
30
- ? (_a = client.config.commands.interactionCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _a === void 0 ? void 0 : _a.permissions
28
+ if (cmd instanceof SlashCommandBuilder_1.SlashCommandBuilder && client.config.commands.slashCommand.setRequiredPermissions) {
29
+ const permissions = client.config.commands.slashCommand.permissions.enabled
30
+ ? (_a = client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _a === void 0 ? void 0 : _a.permissions
31
31
  : undefined;
32
- if (permissions)
32
+ if (permissions) {
33
33
  cmd.setRequiredMemberPermissions(...permissions);
34
- client.commands.interactionCommands[cmd.name] = cmd;
35
- if (client.isClientLogsEnabled())
36
- client.logger.debug(`Set required permissions for ${cmd.name}`);
34
+ if (client.isClientLogsEnabled())
35
+ client.logger.debug(`Set required permissions for ${cmd.name}`);
36
+ }
37
+ client.commands.slashCommands[cmd.name] = cmd;
37
38
  return cmd.toJSON();
38
39
  }
39
40
  return cmd.toJSON();
@@ -43,21 +44,21 @@ function registerInteractionCommands(options) {
43
44
  if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
44
45
  (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).then(() => {
45
46
  if (client.isClientLogsEnabled())
46
- client.logger.warn('No guilds were specified for interaction commands. Registered interaction commands globally.');
47
+ client.logger.warn('No guilds were specified for application commands. Registered application commands globally.');
47
48
  });
48
49
  }
49
50
  else {
50
51
  if (client.isClientLogsEnabled())
51
- client.logger.warn(`Registering ${commands.length} interaction commands to ${guilds.length} guild(s).`);
52
+ client.logger.warn(`Registering ${commands.length} application commands to ${guilds.length} guild(s).`);
52
53
  for (const guild of guilds) {
53
54
  if (!guild)
54
55
  continue;
55
56
  (_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).then(() => {
56
57
  if (client.isClientLogsEnabled())
57
- client.logger.warn(`Registered ${commands.length} interaction command(s) for ${guild}.`);
58
+ client.logger.warn(`Registered ${commands.length} application command(s) for ${guild}.`);
58
59
  });
59
60
  }
60
61
  }
61
62
  });
62
63
  }
63
- exports.registerInteractionCommands = registerInteractionCommands;
64
+ exports.registerApplicationCommands = registerApplicationCommands;
@@ -1,17 +1,17 @@
1
- import { InteractionCommandBuilder, InteractionCommandExecuteData } from '../classes/builders/InteractionCommandBuilder';
2
1
  import { MessageCommandBuilder, MessageCommandExecuteData } from '../classes/builders/MessageCommandBuilder';
2
+ import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builders/SlashCommandBuilder';
3
3
  /**
4
4
  * Reciple command builders
5
5
  */
6
- export declare type RecipleCommandBuilder = MessageCommandBuilder | InteractionCommandBuilder;
6
+ export declare type CommandBuilder = MessageCommandBuilder | SlashCommandBuilder;
7
7
  /**
8
8
  * Reciple command builders execute data
9
9
  */
10
- export declare type RecipleCommandBuildersExecuteData = InteractionCommandExecuteData | MessageCommandExecuteData;
10
+ export declare type CommandBuilderExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
11
11
  /**
12
12
  * Types of Reciple command builders
13
13
  */
14
- export declare enum RecipleCommandBuilderType {
14
+ export declare enum CommandBuilderType {
15
15
  MessageCommand = 0,
16
- InteractionCommand = 1
16
+ SlashCommand = 1
17
17
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecipleCommandBuilderType = void 0;
3
+ exports.CommandBuilderType = void 0;
4
4
  /**
5
5
  * Types of Reciple command builders
6
6
  */
7
- var RecipleCommandBuilderType;
8
- (function (RecipleCommandBuilderType) {
9
- RecipleCommandBuilderType[RecipleCommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
10
- RecipleCommandBuilderType[RecipleCommandBuilderType["InteractionCommand"] = 1] = "InteractionCommand";
11
- })(RecipleCommandBuilderType = exports.RecipleCommandBuilderType || (exports.RecipleCommandBuilderType = {}));
7
+ var CommandBuilderType;
8
+ (function (CommandBuilderType) {
9
+ CommandBuilderType[CommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
10
+ CommandBuilderType[CommandBuilderType["SlashCommand"] = 1] = "SlashCommand";
11
+ })(CommandBuilderType = exports.CommandBuilderType || (exports.CommandBuilderType = {}));
@@ -1,40 +1,40 @@
1
- import { InteractionCommandBuilder, InteractionCommandExecuteData } from '../classes/builders/InteractionCommandBuilder';
2
1
  import { MessageCommandExecuteData } from '../classes/builders/MessageCommandBuilder';
2
+ import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builders/SlashCommandBuilder';
3
3
  import { CooledDownUser } from '../classes/CommandCooldownManager';
4
4
  import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
5
- import { RecipleCommandBuilder } from '../types/builders';
5
+ import { CommandBuilder } from '../types/builders';
6
6
  /**
7
7
  * Halted command's data
8
8
  */
9
- export declare type RecipleHaltedCommandData<Builder extends RecipleCommandBuilder = RecipleCommandBuilder> = RecipleCommandErrorData<Builder> | RecipleCommandCooldownData<Builder> | (Builder extends InteractionCommandBuilder ? never : RecipleCommandInvalidArguments<Builder> | RecipleCommandMissingArguments<Builder>) | RecipleCommandMissingMemberPermissions<Builder> | RecipleCommandMissingBotPermissions<Builder>;
10
- export interface RecipleCommandHaltBaseData<Builder extends RecipleCommandBuilder> {
11
- executeData: Builder extends InteractionCommandBuilder ? InteractionCommandExecuteData : MessageCommandExecuteData;
9
+ export declare type HaltedCommandData<Builder extends CommandBuilder = CommandBuilder> = CommandErrorData<Builder> | CommandCooldownData<Builder> | (Builder extends SlashCommandBuilder ? never : CommandInvalidArguments<Builder> | CommandMissingArguments<Builder>) | CommandMissingMemberPermissions<Builder> | CommandMissingBotPermissions<Builder>;
10
+ export interface CommandHaltBaseData<Builder extends CommandBuilder> {
11
+ executeData: Builder extends SlashCommandBuilder ? SlashCommandExecuteData : MessageCommandExecuteData;
12
12
  }
13
- export interface RecipleCommandErrorData<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
14
- reason: RecipleHaltedCommandReason.Error;
13
+ export interface CommandErrorData<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
14
+ reason: HaltedCommandReason.Error;
15
15
  error: any;
16
16
  }
17
- export interface RecipleCommandCooldownData<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder>, CooledDownUser {
18
- reason: RecipleHaltedCommandReason.Cooldown;
17
+ export interface CommandCooldownData<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder>, CooledDownUser {
18
+ reason: HaltedCommandReason.Cooldown;
19
19
  }
20
- export interface RecipleCommandInvalidArguments<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
21
- reason: RecipleHaltedCommandReason.InvalidArguments;
20
+ export interface CommandInvalidArguments<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
21
+ reason: HaltedCommandReason.InvalidArguments;
22
22
  invalidArguments: MessageCommandOptionManager;
23
23
  }
24
- export interface RecipleCommandMissingArguments<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
25
- reason: RecipleHaltedCommandReason.MissingArguments;
24
+ export interface CommandMissingArguments<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
25
+ reason: HaltedCommandReason.MissingArguments;
26
26
  missingArguments: MessageCommandOptionManager;
27
27
  }
28
- export interface RecipleCommandMissingMemberPermissions<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
29
- reason: RecipleHaltedCommandReason.MissingMemberPermissions;
28
+ export interface CommandMissingMemberPermissions<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
29
+ reason: HaltedCommandReason.MissingMemberPermissions;
30
30
  }
31
- export interface RecipleCommandMissingBotPermissions<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
32
- reason: RecipleHaltedCommandReason.MissingBotPermissions;
31
+ export interface CommandMissingBotPermissions<Builder extends CommandBuilder> extends CommandHaltBaseData<Builder> {
32
+ reason: HaltedCommandReason.MissingBotPermissions;
33
33
  }
34
34
  /**
35
35
  * Command halt reasons
36
36
  */
37
- export declare enum RecipleHaltedCommandReason {
37
+ export declare enum HaltedCommandReason {
38
38
  Error = 0,
39
39
  Cooldown = 1,
40
40
  InvalidArguments = 2,
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecipleHaltedCommandReason = void 0;
3
+ exports.HaltedCommandReason = void 0;
4
4
  /**
5
5
  * Command halt reasons
6
6
  */
7
- var RecipleHaltedCommandReason;
8
- (function (RecipleHaltedCommandReason) {
9
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["Error"] = 0] = "Error";
10
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["Cooldown"] = 1] = "Cooldown";
11
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["InvalidArguments"] = 2] = "InvalidArguments";
12
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingArguments"] = 3] = "MissingArguments";
13
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
14
- RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
15
- })(RecipleHaltedCommandReason = exports.RecipleHaltedCommandReason || (exports.RecipleHaltedCommandReason = {}));
7
+ var HaltedCommandReason;
8
+ (function (HaltedCommandReason) {
9
+ HaltedCommandReason[HaltedCommandReason["Error"] = 0] = "Error";
10
+ HaltedCommandReason[HaltedCommandReason["Cooldown"] = 1] = "Cooldown";
11
+ HaltedCommandReason[HaltedCommandReason["InvalidArguments"] = 2] = "InvalidArguments";
12
+ HaltedCommandReason[HaltedCommandReason["MissingArguments"] = 3] = "MissingArguments";
13
+ HaltedCommandReason[HaltedCommandReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
14
+ HaltedCommandReason[HaltedCommandReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
15
+ })(HaltedCommandReason = exports.HaltedCommandReason || (exports.HaltedCommandReason = {}));
@@ -2,23 +2,23 @@ import { RecipleClient } from '../classes/RecipleClient';
2
2
  import { Config } from '../classes/RecipleConfig';
3
3
  import { RecipleModule, RecipleScript } from '../modules';
4
4
  import { ApplicationCommandBuilder } from '../registerInteractionCommands';
5
- import { RecipleCommandBuilder } from './builders';
5
+ import { CommandBuilder } from './builders';
6
6
  import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
7
- export interface RecipleAddModuleOptions {
7
+ export interface RecipleClientAddModuleOptions {
8
8
  /**
9
9
  * The Module script
10
10
  */
11
11
  script: RecipleScript;
12
12
  /**
13
- * Register interaction commands if possible
13
+ * Register application commands if possible
14
14
  */
15
- registerInteractionCommands?: boolean;
15
+ registerApplicationCommands?: boolean;
16
16
  /**
17
17
  * Module optional info
18
18
  */
19
19
  moduleInfo?: RecipleModule["info"];
20
20
  }
21
- export interface RecipleRegisterInteractionCommandsOptions {
21
+ export interface RegisterApplicationCommandsOptions {
22
22
  /**
23
23
  * Bot client
24
24
  */
@@ -27,13 +27,13 @@ export interface RecipleRegisterInteractionCommandsOptions {
27
27
  * Commands to register
28
28
  */
29
29
  commands: (ApplicationCommandData | ApplicationCommandBuilder)[];
30
- /**PermissionResolvable
30
+ /**
31
31
  * Set guild to not register commands globally
32
32
  */
33
33
  guilds?: string | string[];
34
34
  }
35
- export interface RecipleUserHasCommandPermissionsOptions {
36
- builder: RecipleCommandBuilder;
35
+ export interface UserHasCommandPermissionsOptions {
36
+ builder: CommandBuilder;
37
37
  memberPermissions?: PermissionsBitField;
38
- commandPermissions?: Config["commands"]["interactionCommand"]["permissions"] | Config["commands"]["messageCommand"]["permissions"];
38
+ commandPermissions?: Config["commands"]["slashCommand"]["permissions"] | Config["commands"]["messageCommand"]["permissions"];
39
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "3.1.4",
3
+ "version": "4.0.0-pre.3",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -19,10 +19,10 @@
19
19
  "url": "https://github.com/FalloutStudios/reciple/issues"
20
20
  },
21
21
  "scripts": {
22
- "clean": "rm -rf bin",
22
+ "clean": "yarn exec rimraf bin",
23
23
  "build": "yarn clean && yarn exec tsc",
24
24
  "build:publish": "yarn build && yarn npm publish && yarn build:docs && yarn publish:docs",
25
- "build:pub-prerelease": "yarn build && yarn publish --tag pre",
25
+ "build:pub-prerelease": "yarn build && yarn npm publish --tag pre",
26
26
  "build:docs": "yarn exec typedoc --tsconfig ./docs/typedoc.json",
27
27
  "update:docs": "yarn workspace docs update",
28
28
  "test": "yarn build && yarn test:start",
@@ -58,8 +58,8 @@
58
58
  "devDependencies": {
59
59
  "@types/node": "^18.6.1",
60
60
  "@types/semver": "^7.3.10",
61
- "better-docs": "^2.7.2",
62
61
  "discord.js": "^14.0.3",
62
+ "rimraf": "^3.0.2",
63
63
  "typedoc": "^0.23.9",
64
64
  "typedoc-plugin-discord-types": "^1.0.2",
65
65
  "typedoc-plugin-djs-links": "^1.2.0",
@@ -67,7 +67,7 @@
67
67
  "typescript": "^4.7.4"
68
68
  },
69
69
  "peerDependencies": {
70
- "discord.js": "14.0.x"
70
+ "discord.js": "^14.0.3"
71
71
  },
72
72
  "packageManager": "yarn@3.2.2"
73
73
  }
@@ -27,7 +27,7 @@ commands:
27
27
  permissions: ['Administrator']
28
28
 
29
29
  # Interaction command options
30
- interactionCommand:
30
+ slashCommand:
31
31
  # enable interaction commands
32
32
  enabled: true
33
33
  # reply when an error occured
@@ -116,5 +116,8 @@ ignoredFiles: []
116
116
  # Modules folder
117
117
  modulesFolder: 'modules'
118
118
 
119
+ # Load modules regardless of its supported versions
120
+ disableVersionCheck: false
121
+
119
122
  # Current version
120
123
  version: ^VERSION
@@ -1,50 +0,0 @@
1
- import { RecipleCommandBuilderType } from '../../types/builders';
2
- import { RecipleHaltedCommandData } from '../../types/commands';
3
- import { RecipleClient } from '../RecipleClient';
4
- import { Awaitable, ChatInputCommandInteraction, PermissionResolvable, SlashCommandBuilder } from 'discord.js';
5
- /**
6
- * Execute data for interaction command
7
- */
8
- export interface InteractionCommandExecuteData {
9
- interaction: ChatInputCommandInteraction;
10
- builder: InteractionCommandBuilder;
11
- client: RecipleClient<true>;
12
- }
13
- /**
14
- * Reciple builder for interaction/slash command
15
- */
16
- export declare class InteractionCommandBuilder extends SlashCommandBuilder {
17
- readonly builder = RecipleCommandBuilderType.InteractionCommand;
18
- cooldown: number;
19
- requiredBotPermissions: PermissionResolvable[];
20
- requiredMemberPermissions: PermissionResolvable[];
21
- allowExecuteInDM: boolean;
22
- halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>;
23
- execute: (executeData: InteractionCommandExecuteData) => Awaitable<void>;
24
- /**
25
- * Sets the execute cooldown for this command.
26
- * - `0` means no cooldown
27
- * @param cooldown Command cooldown in milliseconds
28
- */
29
- setCooldown(cooldown: number): InteractionCommandBuilder;
30
- /**
31
- * Set required bot permissions to execute the command
32
- * @param permissions Bot's required permissions
33
- */
34
- setRequiredBotPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
35
- /**
36
- * Set required permissions to execute the command
37
- * @param permissions User's return permissions
38
- */
39
- setRequiredMemberPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
40
- /**
41
- * Function when the command is interupted
42
- * @param halt Function to execute when command is halted
43
- */
44
- setHalt(halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>): InteractionCommandBuilder;
45
- /**
46
- * Function when the command is executed
47
- * @param execute Function to execute when the command is called
48
- */
49
- setExecute(execute: (executeData: InteractionCommandExecuteData) => void): InteractionCommandBuilder;
50
- }