reciple 2.0.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,12 +17,6 @@ To install the bot, run the following command in your terminal:
17
17
  ```bash
18
18
  npm i reciple
19
19
  ```
20
- ```bash
21
- yarn add reciple
22
- ```
23
- ```bash
24
- pnpm add reciple
25
- ```
26
20
 
27
21
  You can initialize the bot to the current directory with the following command in your terminal:
28
22
 
package/bin/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  export * from './reciple/classes/RecipleClient';
2
2
  export * from './reciple/classes/RecipleConfig';
3
+ export * from './reciple/classes/CommandCooldownManager';
3
4
  export * from './reciple/classes/MessageCommandOptionManager';
4
5
  export * from './reciple/classes/builders/InteractionCommandBuilder';
5
6
  export * from './reciple/classes/builders/MessageCommandBuilder';
6
7
  export * from './reciple/classes/builders/MessageCommandOptionBuilder';
7
8
  export * from './reciple/types/builders';
8
9
  export * from './reciple/types/commands';
10
+ export * from './reciple/types/paramOptions';
9
11
  export * from './reciple/permissions';
10
12
  export * from './reciple/flags';
11
- export * from './reciple/isIgnoredChannel';
12
13
  export * from './reciple/logger';
13
14
  export * from './reciple/modules';
14
15
  export * from './reciple/registerInteractionCommands';
package/bin/index.js CHANGED
@@ -16,15 +16,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./reciple/classes/RecipleClient"), exports);
18
18
  __exportStar(require("./reciple/classes/RecipleConfig"), exports);
19
+ __exportStar(require("./reciple/classes/CommandCooldownManager"), exports);
19
20
  __exportStar(require("./reciple/classes/MessageCommandOptionManager"), exports);
20
21
  __exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
21
22
  __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
22
23
  __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
23
24
  __exportStar(require("./reciple/types/builders"), exports);
24
25
  __exportStar(require("./reciple/types/commands"), exports);
26
+ __exportStar(require("./reciple/types/paramOptions"), exports);
25
27
  __exportStar(require("./reciple/permissions"), exports);
26
28
  __exportStar(require("./reciple/flags"), exports);
27
- __exportStar(require("./reciple/isIgnoredChannel"), exports);
28
29
  __exportStar(require("./reciple/logger"), exports);
29
30
  __exportStar(require("./reciple/modules"), exports);
30
31
  __exportStar(require("./reciple/registerInteractionCommands"), exports);
@@ -1,9 +1,9 @@
1
+ import { RecipleCommandBuilderType } from '../types/builders';
1
2
  import { Guild, TextBasedChannel, User } from 'discord.js';
2
- import { RecipleCommandBuilders } from '../types/builders';
3
3
  export interface CooledDownUser {
4
4
  user: User;
5
5
  command: string;
6
- type: RecipleCommandBuilders["builder"];
6
+ type: RecipleCommandBuilderType;
7
7
  guild?: Guild | null;
8
8
  channel?: TextBasedChannel;
9
9
  expireTime: number;
@@ -1,20 +1,21 @@
1
+ import { RecipleCommandBuilders, RecipleCommandBuilderType } from '../types/builders';
1
2
  import { InteractionCommandBuilder, RecipleInteractionCommandExecuteData } from './builders/InteractionCommandBuilder';
2
3
  import { MessageCommandBuilder, RecipleMessageCommandExecuteData } from './builders/MessageCommandBuilder';
3
4
  import { InteractionBuilder } from '../registerInteractionCommands';
4
- import { RecipleCommandBuilders } from '../types/builders';
5
5
  import { CommandCooldownManager } from './CommandCooldownManager';
6
- import { RecipleModule, RecipleScript } from '../modules';
7
6
  import { Logger as ILogger } from 'fallout-utility';
7
+ import { AddModuleOptions } from '../types/paramOptions';
8
+ import { RecipleModule } from '../modules';
8
9
  import { Config } from './RecipleConfig';
9
- import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, CommandInteraction, Interaction, Message } from 'discord.js';
10
+ import { ApplicationCommandData, Awaitable, Client, ClientEvents, ClientOptions, CommandInteraction, Interaction, Message } from 'discord.js';
10
11
  export interface RecipleClientOptions extends ClientOptions {
11
12
  config?: Config;
12
13
  }
13
14
  export interface RecipleClientCommands {
14
- MESSAGE_COMMANDS: {
15
+ messageCommands: {
15
16
  [commandName: string]: MessageCommandBuilder;
16
17
  };
17
- INTERACTION_COMMANDS: {
18
+ interactionCommands: {
18
19
  [commandName: string]: InteractionCommandBuilder;
19
20
  };
20
21
  }
@@ -39,14 +40,14 @@ export interface RecipleClient<Ready extends boolean = boolean> extends Client<R
39
40
  export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
40
41
  config: Config;
41
42
  commands: RecipleClientCommands;
42
- otherApplicationCommandData: (InteractionBuilder | ApplicationCommandDataResolvable)[];
43
+ otherApplicationCommandData: (InteractionBuilder | ApplicationCommandData)[];
43
44
  commandCooldowns: CommandCooldownManager;
44
45
  modules: RecipleModule[];
45
46
  logger: ILogger;
46
47
  version: string;
47
48
  constructor(options: RecipleClientOptions);
48
49
  /**
49
- * Load modules
50
+ * Load modules from modules folder
50
51
  */
51
52
  startModules(folder?: string): Promise<RecipleClient<Ready>>;
52
53
  /**
@@ -56,7 +57,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
56
57
  /**
57
58
  * Add module
58
59
  */
59
- addModule(script: RecipleScript, registerCommands?: boolean, info?: RecipleModule['info']): Promise<void>;
60
+ addModule(options: AddModuleOptions): Promise<void>;
60
61
  /**
61
62
  * Add interaction or message command to client
62
63
  */
@@ -80,8 +81,8 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
80
81
  /**
81
82
  * Get command builder by name or alias if it's a message command
82
83
  */
83
- findCommand(command: string, type: MessageCommandBuilder["builder"]): MessageCommandBuilder | undefined;
84
- findCommand(command: string, type: InteractionCommandBuilder["builder"]): InteractionCommandBuilder | undefined;
84
+ findCommand(command: string, type: RecipleCommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
85
+ findCommand(command: string, type: RecipleCommandBuilderType.InteractionCommand): InteractionCommandBuilder | undefined;
85
86
  /**
86
87
  * Returns true if client logs is enabled
87
88
  */
@@ -11,14 +11,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.RecipleClient = void 0;
14
- const registerInteractionCommands_1 = require("../registerInteractionCommands");
14
+ const builders_1 = require("../types/builders");
15
15
  const permissions_1 = require("../permissions");
16
+ const registerInteractionCommands_1 = require("../registerInteractionCommands");
16
17
  const CommandCooldownManager_1 = require("./CommandCooldownManager");
17
18
  const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
18
- const modules_1 = require("../modules");
19
19
  const fallout_utility_1 = require("fallout-utility");
20
+ const commands_1 = require("../types/commands");
21
+ const modules_1 = require("../modules");
20
22
  const RecipleConfig_1 = require("./RecipleConfig");
21
- const isIgnoredChannel_1 = require("../isIgnoredChannel");
22
23
  const version_1 = require("../version");
23
24
  const logger_1 = require("../logger");
24
25
  const discord_js_1 = require("discord.js");
@@ -27,7 +28,7 @@ class RecipleClient extends discord_js_1.Client {
27
28
  var _a, _b, _c;
28
29
  super(options);
29
30
  this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
30
- this.commands = { MESSAGE_COMMANDS: {}, INTERACTION_COMMANDS: {} };
31
+ this.commands = { messageCommands: {}, interactionCommands: {} };
31
32
  this.otherApplicationCommandData = [];
32
33
  this.commandCooldowns = new CommandCooldownManager_1.CommandCooldownManager();
33
34
  this.modules = [];
@@ -40,7 +41,7 @@ class RecipleClient extends discord_js_1.Client {
40
41
  this.logger.logFile(this.config.fileLogging.logFilePath, false);
41
42
  }
42
43
  /**
43
- * Load modules
44
+ * Load modules from modules folder
44
45
  */
45
46
  startModules(folder) {
46
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -79,11 +80,15 @@ class RecipleClient extends discord_js_1.Client {
79
80
  }
80
81
  if (this.isClientLogsEnabled()) {
81
82
  this.logger.info(`${this.modules.length} modules loaded.`);
82
- this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
83
- this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
83
+ this.logger.info(`${Object.keys(this.commands.messageCommands).length} message commands loaded.`);
84
+ this.logger.info(`${Object.keys(this.commands.interactionCommands).length} interaction commands loaded.`);
84
85
  }
85
86
  if (this.config.commands.interactionCommand.registerCommands) {
86
- yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
87
+ yield (0, registerInteractionCommands_1.registerInteractionCommands)({
88
+ client: this,
89
+ commands: [...Object.values(this.commands.interactionCommands), ...this.otherApplicationCommandData],
90
+ guilds: this.config.commands.interactionCommand.guilds
91
+ });
87
92
  }
88
93
  return this;
89
94
  });
@@ -91,9 +96,12 @@ class RecipleClient extends discord_js_1.Client {
91
96
  /**
92
97
  * Add module
93
98
  */
94
- addModule(script, registerCommands = true, info) {
99
+ addModule(options) {
95
100
  var _a;
96
101
  return __awaiter(this, void 0, void 0, function* () {
102
+ const { script } = options;
103
+ const registerCommands = options.registerInteractionCommands;
104
+ const info = options.moduleInfo;
97
105
  this.modules.push({
98
106
  script,
99
107
  info: Object.assign({ filename: undefined, versions: typeof script.versions == 'string' ? [script.versions] : script.versions, path: undefined }, info)
@@ -107,9 +115,12 @@ class RecipleClient extends discord_js_1.Client {
107
115
  continue;
108
116
  this.addCommand(command);
109
117
  }
110
- if (!registerCommands || !this.config.commands.interactionCommand.registerCommands)
111
- return;
112
- yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
118
+ if (registerCommands)
119
+ yield (0, registerInteractionCommands_1.registerInteractionCommands)({
120
+ client: this,
121
+ commands: [...Object.values(this.commands.interactionCommands), ...this.otherApplicationCommandData],
122
+ guilds: this.config.commands.interactionCommand.guilds
123
+ });
113
124
  });
114
125
  }
115
126
  /**
@@ -117,11 +128,11 @@ class RecipleClient extends discord_js_1.Client {
117
128
  */
118
129
  addCommand(command) {
119
130
  var _a;
120
- if (command.builder === 'MESSAGE_COMMAND') {
121
- this.commands.MESSAGE_COMMANDS[command.name] = command;
131
+ if (command.builder === builders_1.RecipleCommandBuilderType.MessageCommand) {
132
+ this.commands.messageCommands[command.name] = command;
122
133
  }
123
- else if (command.builder === 'INTERACTION_COMMAND') {
124
- this.commands.INTERACTION_COMMANDS[command.name] = command;
134
+ else if (command.builder === builders_1.RecipleCommandBuilderType.InteractionCommand) {
135
+ this.commands.interactionCommands[command.name] = command;
125
136
  }
126
137
  else if (this.isClientLogsEnabled()) {
127
138
  this.logger.error(`Unknow command "${(_a = typeof command) !== null && _a !== void 0 ? _a : 'unknown'}".`);
@@ -146,10 +157,10 @@ class RecipleClient extends discord_js_1.Client {
146
157
  return __awaiter(this, void 0, void 0, function* () {
147
158
  if (!message.content || !this.isReady())
148
159
  return;
149
- const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
160
+ const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.commands.messageCommand.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
150
161
  if (!parseCommand || !(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command))
151
162
  return;
152
- const command = this.findCommand(parseCommand.command, 'MESSAGE_COMMAND');
163
+ const command = this.findCommand(parseCommand.command, builders_1.RecipleCommandBuilderType.MessageCommand);
153
164
  if (!command)
154
165
  return;
155
166
  const commandOptions = command.getCommandOptionValues(parseCommand);
@@ -160,28 +171,28 @@ class RecipleClient extends discord_js_1.Client {
160
171
  builder: command,
161
172
  client: this
162
173
  };
163
- if ((0, permissions_1.userHasCommandPermissions)(command.name, (_a = message.member) === null || _a === void 0 ? void 0 : _a.permissions, this.config.permissions.messageCommands, command)) {
164
- if (!command.allowExecuteInDM && message.channel.type === 'DM'
174
+ if ((0, permissions_1.userHasCommandPermissions)(command.name, (_a = message.member) === null || _a === void 0 ? void 0 : _a.permissions, this.config.commands.messageCommand.permissions, command)) {
175
+ if (!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM
165
176
  || !command.allowExecuteByBots
166
177
  && (message.author.bot || message.author.system)
167
- || (0, isIgnoredChannel_1.isIgnoredChannel)(message.channelId, this.config.ignoredChannels))
178
+ || (0, permissions_1.isIgnoredChannel)(message.channelId, this.config.ignoredChannels))
168
179
  return;
169
180
  if (command.validateOptions) {
170
181
  if (commandOptions.some(o => o.invalid)) {
171
- if (!(command === null || command === void 0 ? void 0 : command.halt) || !(yield command.halt({ executeData, reason: 'INVALID_ARGUMENTS', invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.invalid)) }))) {
182
+ if (!(command === null || command === void 0 ? void 0 : command.halt) || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.invalid)) }))) {
172
183
  message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this._replyError(er));
173
184
  }
174
185
  return;
175
186
  }
176
187
  if (commandOptions.some(o => o.missing)) {
177
- if (!command.halt || !(yield command.halt({ executeData, reason: 'MISSING_ARGUMENTS', missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.missing)) }))) {
178
- message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
188
+ if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.missing)) }))) {
189
+ message.reply(this.getMessage('missingArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
179
190
  }
180
191
  return;
181
192
  }
182
193
  }
183
194
  if (message.guild && !(0, permissions_1.botHasExecutePermissions)(message.guild, command.requiredBotPermissions)) {
184
- if (!command.halt || !(yield command.halt({ executeData, reason: 'MISSING_BOT_PERMISSIONS' }))) {
195
+ if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingBotPermissions }))) {
185
196
  message.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
186
197
  }
187
198
  return;
@@ -191,29 +202,30 @@ class RecipleClient extends discord_js_1.Client {
191
202
  command: command.name,
192
203
  channel: message.channel,
193
204
  guild: message.guild,
194
- type: 'MESSAGE_COMMAND'
205
+ type: builders_1.RecipleCommandBuilderType.MessageCommand
195
206
  };
196
207
  if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
197
208
  this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
198
209
  }
199
210
  else if (this.config.commands.messageCommand.enableCooldown && command.cooldown) {
200
- if (!command.halt || !(yield command.halt(Object.assign({ executeData, reason: 'COOLDOWN' }, this.commandCooldowns.get(userCooldown))))) {
211
+ if (!command.halt || !(yield command.halt(Object.assign({ executeData, reason: commands_1.RecipleHaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
201
212
  yield message.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
202
213
  }
203
214
  return;
204
215
  }
205
216
  try {
206
- yield Promise.resolve(command.execute(executeData)).catch((err) => __awaiter(this, void 0, void 0, function* () { return !command.halt || !(yield command.halt({ executeData, reason: 'ERROR', error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
207
- this.emit('recipleMessageCommandCreate', executeData);
217
+ yield Promise.resolve(command.execute(executeData))
218
+ .then(() => this.emit('recipleMessageCommandCreate', executeData))
219
+ .catch((err) => __awaiter(this, void 0, void 0, function* () { return !command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
208
220
  return executeData;
209
221
  }
210
222
  catch (err) {
211
- if (!command.halt || !(yield command.halt({ executeData, reason: 'ERROR', error: err }))) {
223
+ if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err }))) {
212
224
  this._commandExecuteError(err, executeData);
213
225
  }
214
226
  }
215
227
  }
216
- else if (!command.halt || !(yield command.halt({ executeData, reason: 'MISSING_MEMBER_PERMISSIONS' }))) {
228
+ else if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingMemberPermissions }))) {
217
229
  message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
218
230
  }
219
231
  });
@@ -224,9 +236,9 @@ class RecipleClient extends discord_js_1.Client {
224
236
  interactionCommandExecute(interaction) {
225
237
  var _a, _b;
226
238
  return __awaiter(this, void 0, void 0, function* () {
227
- if (!interaction || !interaction.isCommand() || !this.isReady())
239
+ if (!interaction || interaction.type !== discord_js_1.InteractionType.ApplicationCommand || !this.isReady())
228
240
  return;
229
- const command = this.findCommand(interaction.commandName, 'INTERACTION_COMMAND');
241
+ const command = this.findCommand(interaction.commandName, builders_1.RecipleCommandBuilderType.InteractionCommand);
230
242
  if (!command)
231
243
  return;
232
244
  const executeData = {
@@ -234,11 +246,11 @@ class RecipleClient extends discord_js_1.Client {
234
246
  builder: command,
235
247
  client: this
236
248
  };
237
- if ((0, permissions_1.userHasCommandPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.permissions.interactionCommands, command)) {
238
- if (!command || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
249
+ if ((0, permissions_1.userHasCommandPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.commands.interactionCommand.permissions, command)) {
250
+ if (!command || (0, permissions_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
239
251
  return;
240
252
  if (interaction.guild && !(0, permissions_1.botHasExecutePermissions)(interaction.guild, command.requiredBotPermissions)) {
241
- if (!command.halt || !(yield command.halt({ executeData, reason: 'MISSING_BOT_PERMISSIONS' }))) {
253
+ if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingBotPermissions }))) {
242
254
  yield interaction.reply(this.getMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
243
255
  }
244
256
  return;
@@ -248,29 +260,30 @@ class RecipleClient extends discord_js_1.Client {
248
260
  command: command.name,
249
261
  channel: (_b = interaction.channel) !== null && _b !== void 0 ? _b : undefined,
250
262
  guild: interaction.guild,
251
- type: 'INTERACTION_COMMAND'
263
+ type: builders_1.RecipleCommandBuilderType.InteractionCommand
252
264
  };
253
265
  if (this.config.commands.interactionCommand.enableCooldown && command.cooldown && !this.commandCooldowns.isCooledDown(userCooldown)) {
254
266
  this.commandCooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
255
267
  }
256
268
  else if (this.config.commands.interactionCommand.enableCooldown && command.cooldown) {
257
- if (!command.halt || !(yield command.halt(Object.assign({ executeData, reason: 'COOLDOWN' }, this.commandCooldowns.get(userCooldown))))) {
269
+ if (!command.halt || !(yield command.halt(Object.assign({ executeData, reason: commands_1.RecipleHaltedCommandReason.Cooldown }, this.commandCooldowns.get(userCooldown))))) {
258
270
  yield interaction.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
259
271
  }
260
272
  return;
261
273
  }
262
274
  try {
263
- yield Promise.resolve(command.execute(executeData)).catch((err) => __awaiter(this, void 0, void 0, function* () { return !command.halt || !(yield command.halt({ executeData, reason: 'ERROR', error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
264
- this.emit('recipleInteractionCommandCreate', executeData);
275
+ yield Promise.resolve(command.execute(executeData))
276
+ .then(() => this.emit('recipleInteractionCommandCreate', executeData))
277
+ .catch((err) => __awaiter(this, void 0, void 0, function* () { return !command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err })) ? this._commandExecuteError(err, executeData) : void 0; }));
265
278
  return executeData;
266
279
  }
267
280
  catch (err) {
268
- if (!command.halt || !(yield command.halt({ executeData, reason: 'ERROR', error: err }))) {
281
+ if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.Error, error: err }))) {
269
282
  this._commandExecuteError(err, executeData);
270
283
  }
271
284
  }
272
285
  }
273
- else if (!command.halt || !(yield command.halt({ executeData, reason: 'MISSING_MEMBER_PERMISSIONS' }))) {
286
+ else if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingMemberPermissions }))) {
274
287
  yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
275
288
  }
276
289
  });
@@ -285,11 +298,11 @@ class RecipleClient extends discord_js_1.Client {
285
298
  findCommand(command, type) {
286
299
  var _a;
287
300
  switch (type) {
288
- case 'INTERACTION_COMMAND':
289
- return this.commands.INTERACTION_COMMANDS[command];
290
- case 'MESSAGE_COMMAND':
291
- return (_a = this.commands.MESSAGE_COMMANDS[command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
292
- ? Object.values(this.commands.MESSAGE_COMMANDS).find(c => c.aliases.some(a => a == (command === null || command === void 0 ? void 0 : command.toLowerCase())))
301
+ case builders_1.RecipleCommandBuilderType.InteractionCommand:
302
+ return this.commands.interactionCommands[command];
303
+ case builders_1.RecipleCommandBuilderType.MessageCommand:
304
+ return (_a = this.commands.messageCommands[command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
305
+ ? Object.values(this.commands.messageCommands).find(c => c.aliases.some(a => a == (command === null || command === void 0 ? void 0 : command.toLowerCase())))
293
306
  : undefined);
294
307
  default:
295
308
  throw new TypeError('Unknown command type');
@@ -313,7 +326,7 @@ class RecipleClient extends discord_js_1.Client {
313
326
  _commandExecuteError(err, command) {
314
327
  return __awaiter(this, void 0, void 0, function* () {
315
328
  if (this.isClientLogsEnabled()) {
316
- this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
329
+ this.logger.error(`An error occured executing ${command.builder.builder == builders_1.RecipleCommandBuilderType.MessageCommand ? 'message' : 'interaction'} command "${command.builder.name}"`);
317
330
  this.logger.error(err);
318
331
  }
319
332
  if (!err || !command)
@@ -5,14 +5,18 @@ export interface ConfigCommandPermissions {
5
5
  }
6
6
  export interface Config {
7
7
  token: string;
8
- prefix: string;
9
8
  commands: {
10
9
  messageCommand: {
11
10
  enabled: boolean;
11
+ prefix?: string;
12
12
  replyOnError: boolean;
13
13
  allowCommandAlias: boolean;
14
14
  enableCooldown: boolean;
15
15
  commandArgumentSeparator: string;
16
+ permissions: {
17
+ enabled: boolean;
18
+ commands: ConfigCommandPermissions[];
19
+ };
16
20
  };
17
21
  interactionCommand: {
18
22
  enabled: boolean;
@@ -20,17 +24,11 @@ export interface Config {
20
24
  registerCommands: boolean;
21
25
  enableCooldown: boolean;
22
26
  setRequiredPermissions: boolean;
23
- guilds: string[] | string;
24
- };
25
- };
26
- permissions: {
27
- messageCommands: {
28
- enabled: boolean;
29
- commands: ConfigCommandPermissions[];
30
- };
31
- interactionCommands: {
32
- enabled: boolean;
33
- commands: ConfigCommandPermissions[];
27
+ guilds?: string[] | string;
28
+ permissions: {
29
+ enabled: boolean;
30
+ commands: ConfigCommandPermissions[];
31
+ };
34
32
  };
35
33
  };
36
34
  ignoredChannels: {
@@ -2,18 +2,19 @@ import { Awaitable, CommandInteraction, PermissionResolvable } from 'discord.js'
2
2
  import { RecipleHaltedCommandData } from '../../types/commands';
3
3
  import { SlashCommandBuilder } from '@discordjs/builders';
4
4
  import { RecipleClient } from '../RecipleClient';
5
+ import { RecipleCommandBuilderType } from '../../types/builders';
5
6
  export interface RecipleInteractionCommandExecuteData {
6
7
  interaction: CommandInteraction;
7
8
  builder: InteractionCommandBuilder;
8
9
  client: RecipleClient<true>;
9
10
  }
10
11
  export declare class InteractionCommandBuilder extends SlashCommandBuilder {
11
- readonly builder = "INTERACTION_COMMAND";
12
+ readonly builder = RecipleCommandBuilderType.InteractionCommand;
12
13
  cooldown: number;
13
14
  requiredBotPermissions: PermissionResolvable[];
14
15
  RequiredUserPermissions: PermissionResolvable[];
15
16
  allowExecuteInDM: boolean;
16
- halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean>;
17
+ halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>;
17
18
  execute: (executeData: RecipleInteractionCommandExecuteData) => Awaitable<void>;
18
19
  /**
19
20
  * Sets the execute cooldown for this command.
@@ -27,7 +28,7 @@ export declare class InteractionCommandBuilder extends SlashCommandBuilder {
27
28
  /**
28
29
  * Function when the command is interupted before execution
29
30
  */
30
- setHalt(halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean>): InteractionCommandBuilder;
31
+ setHalt(halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>): InteractionCommandBuilder;
31
32
  /**
32
33
  * Function when the command is executed
33
34
  */
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InteractionCommandBuilder = void 0;
4
4
  const builders_1 = require("@discordjs/builders");
5
+ const builders_2 = require("../../types/builders");
5
6
  class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
6
7
  constructor() {
7
8
  super(...arguments);
8
- this.builder = 'INTERACTION_COMMAND';
9
+ this.builder = builders_2.RecipleCommandBuilderType.InteractionCommand;
9
10
  this.cooldown = 0;
10
11
  this.requiredBotPermissions = [];
11
12
  this.RequiredUserPermissions = [];
@@ -4,6 +4,7 @@ import { Awaitable, Message, PermissionResolvable } from 'discord.js';
4
4
  import { RecipleHaltedCommandData } from '../../types/commands';
5
5
  import { Command as CommandMessage } from 'fallout-utility';
6
6
  import { RecipleClient } from '../RecipleClient';
7
+ import { RecipleCommandBuilderType } from '../../types/builders';
7
8
  export interface RecipleMessageCommandExecuteData {
8
9
  message: Message;
9
10
  options: MessageCommandOptionManager;
@@ -19,7 +20,7 @@ export interface MessageCommandValidatedOption {
19
20
  missing: boolean;
20
21
  }
21
22
  export declare class MessageCommandBuilder {
22
- readonly builder = "MESSAGE_COMMAND";
23
+ readonly builder = RecipleCommandBuilderType.MessageCommand;
23
24
  name: string;
24
25
  cooldown: number;
25
26
  description: string;
@@ -30,7 +31,7 @@ export declare class MessageCommandBuilder {
30
31
  RequiredUserPermissions: PermissionResolvable[];
31
32
  allowExecuteInDM: boolean;
32
33
  allowExecuteByBots: boolean;
33
- halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean>;
34
+ halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
34
35
  execute: (executeData: RecipleMessageCommandExecuteData) => void;
35
36
  /**
36
37
  * Sets the command name
@@ -68,7 +69,7 @@ export declare class MessageCommandBuilder {
68
69
  /**
69
70
  * Function when the command is interupted before execution
70
71
  */
71
- setHalt(halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean>): MessageCommandBuilder;
72
+ setHalt(halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
72
73
  /**
73
74
  * Function when the command is executed
74
75
  */
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageCommandBuilder = void 0;
4
4
  const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
5
+ const builders_1 = require("../../types/builders");
5
6
  class MessageCommandBuilder {
6
7
  constructor() {
7
- this.builder = 'MESSAGE_COMMAND';
8
+ this.builder = builders_1.RecipleCommandBuilderType.MessageCommand;
8
9
  this.name = '';
9
10
  this.cooldown = 0;
10
11
  this.description = '';
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.loadModules = void 0;
16
+ const builders_1 = require("./types/builders");
16
17
  const fs_1 = require("fs");
17
18
  const version_1 = require("./version");
18
19
  const wildcard_match_1 = __importDefault(require("wildcard-match"));
@@ -47,8 +48,9 @@ function loadModules(client, folder) {
47
48
  throw new Error(script + ' onStart is not defined or returned false.');
48
49
  if (module_.commands) {
49
50
  for (const command of module_.commands) {
50
- if (command.builder === 'MESSAGE_COMMAND' || command.builder === 'INTERACTION_COMMAND')
51
+ if (command.builder === builders_1.RecipleCommandBuilderType.MessageCommand || command.builder === builders_1.RecipleCommandBuilderType.InteractionCommand) {
51
52
  commands.push(command);
53
+ }
52
54
  }
53
55
  }
54
56
  }
@@ -65,7 +67,7 @@ function loadModules(client, folder) {
65
67
  client.logger.error(`A ${c.builder} command name is not defined in ${script}`);
66
68
  return false;
67
69
  }
68
- if (c.builder === 'MESSAGE_COMMAND' && c.options.length && c.options.some(o => !o.name)) {
70
+ if (c.builder === builders_1.RecipleCommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
69
71
  if (client.isClientLogsEnabled())
70
72
  client.logger.error(`A ${c.builder} option name is not defined in ${script}`);
71
73
  return false;
@@ -1,8 +1,15 @@
1
- import { Guild, PermissionResolvable, Permissions } from 'discord.js';
1
+ import { Guild, PermissionResolvable, PermissionsBitField } from 'discord.js';
2
2
  import { RecipleCommandBuilders } from './types/builders';
3
3
  import { Config } from './classes/RecipleConfig';
4
4
  /**
5
5
  * Check if the user has permissions to execute the given command name
6
6
  */
7
- export declare function userHasCommandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: RecipleCommandBuilders): boolean;
7
+ export declare function userHasCommandPermissions(commandName: string, memberPermissions?: PermissionsBitField, configConmmandPermissions?: Config['commands']['messageCommand']['permissions'] | Config['commands']['interactionCommand']['permissions'], builder?: RecipleCommandBuilders): boolean;
8
+ /**
9
+ * Check if the bot has the required permissions in a guild
10
+ */
8
11
  export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
12
+ /**
13
+ * Check if the channel id is ignored in config file
14
+ */
15
+ export declare function isIgnoredChannel(channelId: string, ignoredChannelsConfig?: Config["ignoredChannels"]): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
3
+ exports.isIgnoredChannel = exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
4
4
  /**
5
5
  * Check if the user has permissions to execute the given command name
6
6
  */
@@ -14,10 +14,26 @@ function userHasCommandPermissions(commandName, memberPermissions, configConmman
14
14
  return memberPermissions ? memberPermissions.has(command.permissions) : false;
15
15
  }
16
16
  exports.userHasCommandPermissions = userHasCommandPermissions;
17
+ /**
18
+ * Check if the bot has the required permissions in a guild
19
+ */
17
20
  function botHasExecutePermissions(guild, requiredPermissions) {
18
21
  var _a;
19
22
  if (!(requiredPermissions === null || requiredPermissions === void 0 ? void 0 : requiredPermissions.length))
20
23
  return true;
21
- return (guild === null || guild === void 0 ? void 0 : guild.me) ? (_a = guild.me) === null || _a === void 0 ? void 0 : _a.permissions.has(requiredPermissions) : false;
24
+ return (guild === null || guild === void 0 ? void 0 : guild.members.me) ? (_a = guild.members.me) === null || _a === void 0 ? void 0 : _a.permissions.has(requiredPermissions) : false;
22
25
  }
23
26
  exports.botHasExecutePermissions = botHasExecutePermissions;
27
+ /**
28
+ * Check if the channel id is ignored in config file
29
+ */
30
+ function isIgnoredChannel(channelId, ignoredChannelsConfig) {
31
+ if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
32
+ return false;
33
+ if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
34
+ return true;
35
+ if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
36
+ return true;
37
+ return false;
38
+ }
39
+ exports.isIgnoredChannel = isIgnoredChannel;
@@ -1,9 +1,8 @@
1
1
  import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
2
- import { ApplicationCommandDataResolvable } from 'discord.js';
3
- import { RecipleClient } from './classes/RecipleClient';
4
- import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder } from '@discordjs/builders';
5
- export declare type InteractionBuilder = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
2
+ import { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
3
+ import { RegisterInteractionCommandsOptions } from './types/paramOptions';
4
+ export declare type InteractionBuilder = ContextMenuCommandBuilder | InteractionCommandBuilder | SlashCommandBuilder;
6
5
  /**
7
6
  * Register interaction commands
8
7
  */
9
- export declare function registerInteractionCommands(client: RecipleClient, cmds?: (InteractionBuilder | ApplicationCommandDataResolvable)[], overwriteGuilds?: string | string[]): Promise<void>;
8
+ export declare function registerInteractionCommands(options: RegisterInteractionCommandsOptions): Promise<void>;
@@ -10,33 +10,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerInteractionCommands = void 0;
13
+ const InteractionCommandBuilder_1 = require("./classes/builders/InteractionCommandBuilder");
13
14
  /**
14
15
  * Register interaction commands
15
16
  */
16
- function registerInteractionCommands(client, cmds, overwriteGuilds) {
17
- var _a, _b, _c;
17
+ function registerInteractionCommands(options) {
18
+ var _a, _b, _c, _d;
18
19
  return __awaiter(this, void 0, void 0, function* () {
19
- const commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
20
- var _a, _b, _c, _d;
21
- if (typeof c.toJSON == 'undefined')
22
- return c;
23
- const cmd = c;
24
- if ((cmd === null || cmd === void 0 ? void 0 : cmd.builder) === 'INTERACTION_COMMAND' && client.config.commands.interactionCommand.setRequiredPermissions) {
25
- const permissions = (_d = (((_a = client.config.permissions) === null || _a === void 0 ? void 0 : _a.interactionCommands.enabled) ?
26
- (_c = (_b = client.config.permissions) === null || _b === void 0 ? void 0 : _b.interactionCommands.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _c === void 0 ? void 0 : _c.permissions :
27
- undefined)) !== null && _d !== void 0 ? _d : cmd.requiredBotPermissions;
20
+ const client = options.client;
21
+ const guilds = typeof options.guilds == 'string' ? [options.guilds] : options.guilds;
22
+ const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.interactionCommands).map(cmd => {
23
+ var _a, _b;
24
+ if (typeof (cmd === null || cmd === void 0 ? void 0 : cmd.toJSON) == 'undefined')
25
+ return cmd;
26
+ cmd = cmd;
27
+ if (cmd instanceof InteractionCommandBuilder_1.InteractionCommandBuilder && client.config.commands.interactionCommand.setRequiredPermissions) {
28
+ const permissions = (_b = (client.config.commands.interactionCommand.permissions.enabled ?
29
+ (_a = client.config.commands.interactionCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _a === void 0 ? void 0 : _a.permissions :
30
+ undefined)) !== null && _b !== void 0 ? _b : cmd.requiredBotPermissions;
28
31
  cmd.setRequiredMemberPermissions(permissions);
29
- client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
32
+ client.commands.interactionCommands[cmd.name] = cmd;
30
33
  if (client.isClientLogsEnabled())
31
34
  client.logger.debug(`Set required permissions for ${cmd.name}`);
32
35
  return cmd.toJSON();
33
36
  }
34
- return c.toJSON();
35
- })) !== null && _a !== void 0 ? _a : [];
36
- const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : client.config.commands.interactionCommand.guilds;
37
- const guilds = typeof configGuilds === 'object' ? configGuilds : [configGuilds];
37
+ return cmd.toJSON();
38
+ })) !== null && _b !== void 0 ? _b : [];
39
+ if (!client.isReady())
40
+ throw new Error('Client is not ready');
38
41
  if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
39
- (_b = client.application) === null || _b === void 0 ? void 0 : _b.commands.set(commands).then(() => {
42
+ (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).then(() => {
40
43
  if (client.isClientLogsEnabled())
41
44
  client.logger.warn('No guilds were specified for interaction commands. Registered interaction commands globally.');
42
45
  });
@@ -47,7 +50,7 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
47
50
  for (const guild of guilds) {
48
51
  if (!guild)
49
52
  continue;
50
- (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands, guild).then(() => {
53
+ (_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).then(() => {
51
54
  if (client.isClientLogsEnabled())
52
55
  client.logger.warn(`Registered ${commands.length} interaction command(s) for ${guild}.`);
53
56
  });
@@ -2,3 +2,7 @@ import { InteractionCommandBuilder, RecipleInteractionCommandExecuteData } from
2
2
  import { MessageCommandBuilder, RecipleMessageCommandExecuteData } from '../classes/builders/MessageCommandBuilder';
3
3
  export declare type RecipleCommandBuilders = MessageCommandBuilder | InteractionCommandBuilder;
4
4
  export declare type RecipleCommandBuildersExecuteData = RecipleInteractionCommandExecuteData | RecipleMessageCommandExecuteData;
5
+ export declare enum RecipleCommandBuilderType {
6
+ MessageCommand = 0,
7
+ InteractionCommand = 1
8
+ }
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecipleCommandBuilderType = void 0;
4
+ var RecipleCommandBuilderType;
5
+ (function (RecipleCommandBuilderType) {
6
+ RecipleCommandBuilderType[RecipleCommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
7
+ RecipleCommandBuilderType[RecipleCommandBuilderType["InteractionCommand"] = 1] = "InteractionCommand";
8
+ })(RecipleCommandBuilderType = exports.RecipleCommandBuilderType || (exports.RecipleCommandBuilderType = {}));
@@ -3,29 +3,36 @@ import { RecipleMessageCommandExecuteData } from '../classes/builders/MessageCom
3
3
  import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
4
4
  import { CooledDownUser } from '../classes/CommandCooldownManager';
5
5
  import { RecipleCommandBuilders } from '../types/builders';
6
- export declare type CommandHaltReason<Builder extends RecipleCommandBuilders> = RecipleHaltedCommandData<Builder>["reason"];
7
- export declare type RecipleHaltedCommandData<Builder extends RecipleCommandBuilders> = CommandErrorData<Builder> | CommandCooldownData<Builder> | CommandInvalidArguments<Builder> | CommandMissingArguments<Builder> | CommandMissingMemberPermissions<Builder> | CommandMissingBotPermissions<Builder>;
6
+ export declare type RecipleHaltedCommandData<Builder extends RecipleCommandBuilders> = CommandErrorData<Builder> | CommandCooldownData<Builder> | (Builder extends InteractionCommandBuilder ? never : CommandInvalidArguments<Builder> | CommandMissingArguments<Builder>) | CommandMissingMemberPermissions<Builder> | CommandMissingBotPermissions<Builder>;
8
7
  export interface CommandHaltBaseData<Builder extends RecipleCommandBuilders> {
9
8
  executeData: Builder extends InteractionCommandBuilder ? RecipleInteractionCommandExecuteData : RecipleMessageCommandExecuteData;
10
9
  }
11
10
  export interface CommandErrorData<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder> {
12
- reason: 'ERROR';
11
+ reason: RecipleHaltedCommandReason.Error;
13
12
  error: any;
14
13
  }
15
14
  export interface CommandCooldownData<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder>, CooledDownUser {
16
- reason: 'COOLDOWN';
15
+ reason: RecipleHaltedCommandReason.Cooldown;
17
16
  }
18
17
  export interface CommandInvalidArguments<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder> {
19
- reason: 'INVALID_ARGUMENTS';
18
+ reason: RecipleHaltedCommandReason.InvalidArguments;
20
19
  invalidArguments: MessageCommandOptionManager;
21
20
  }
22
21
  export interface CommandMissingArguments<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder> {
23
- reason: 'MISSING_ARGUMENTS';
22
+ reason: RecipleHaltedCommandReason.MissingArguments;
24
23
  missingArguments: MessageCommandOptionManager;
25
24
  }
26
25
  export interface CommandMissingMemberPermissions<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder> {
27
- reason: 'MISSING_MEMBER_PERMISSIONS';
26
+ reason: RecipleHaltedCommandReason.MissingMemberPermissions;
28
27
  }
29
28
  export interface CommandMissingBotPermissions<Builder extends RecipleCommandBuilders> extends CommandHaltBaseData<Builder> {
30
- reason: 'MISSING_BOT_PERMISSIONS';
29
+ reason: RecipleHaltedCommandReason.MissingBotPermissions;
30
+ }
31
+ export declare enum RecipleHaltedCommandReason {
32
+ Error = 0,
33
+ Cooldown = 1,
34
+ InvalidArguments = 2,
35
+ MissingArguments = 3,
36
+ MissingMemberPermissions = 4,
37
+ MissingBotPermissions = 5
31
38
  }
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecipleHaltedCommandReason = void 0;
4
+ var RecipleHaltedCommandReason;
5
+ (function (RecipleHaltedCommandReason) {
6
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["Error"] = 0] = "Error";
7
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["Cooldown"] = 1] = "Cooldown";
8
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["InvalidArguments"] = 2] = "InvalidArguments";
9
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingArguments"] = 3] = "MissingArguments";
10
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
11
+ RecipleHaltedCommandReason[RecipleHaltedCommandReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
12
+ })(RecipleHaltedCommandReason = exports.RecipleHaltedCommandReason || (exports.RecipleHaltedCommandReason = {}));
@@ -0,0 +1,32 @@
1
+ import { InteractionBuilder } from '../registerInteractionCommands';
2
+ import { RecipleModule, RecipleScript } from '../modules';
3
+ import { RecipleClient } from '../classes/RecipleClient';
4
+ import { ApplicationCommandData } from 'discord.js';
5
+ export interface AddModuleOptions {
6
+ /**
7
+ * The Module script
8
+ */
9
+ script: RecipleScript;
10
+ /**
11
+ * Register interaction commands if possible
12
+ */
13
+ registerInteractionCommands?: boolean;
14
+ /**
15
+ * Module optional info
16
+ */
17
+ moduleInfo?: RecipleModule["info"];
18
+ }
19
+ export interface RegisterInteractionCommandsOptions {
20
+ /**
21
+ * Bot client
22
+ */
23
+ client: RecipleClient;
24
+ /**
25
+ * Commands to register
26
+ */
27
+ commands: (ApplicationCommandData | InteractionBuilder)[];
28
+ /**
29
+ * Set guild to not register commands globally
30
+ */
31
+ guilds?: string | string[];
32
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "2.0.2",
3
+ "version": "3.0.1",
4
4
  "description": "Handler for Discord.js",
5
5
  "author": "FalloutStudios",
6
6
  "homepage": "https://reciple.js.org",
7
+ "contributors": [
8
+ "GhexterCortes <cortesghexter@gmail.com>"
9
+ ],
7
10
  "bugs": {
8
11
  "url": "https://github.com/FalloutStudios/reciple/issues"
9
12
  },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/FalloutStudios/reciple.git"
16
+ },
10
17
  "license": "GPL-3.0",
11
18
  "main": "bin/index.js",
12
19
  "bin": {
@@ -36,7 +43,7 @@
36
43
  },
37
44
  "dependencies": {
38
45
  "chalk": "4.1.2",
39
- "commander": "^9.3.0",
46
+ "commander": "^9.4.0",
40
47
  "dotenv": "^16.0.1",
41
48
  "fallout-utility": "^1.4.2",
42
49
  "semver": "^7.3.7",
@@ -44,12 +51,13 @@
44
51
  "yaml": "^2.1.1"
45
52
  },
46
53
  "devDependencies": {
47
- "@types/node": "^18.0.3",
54
+ "@types/node": "^18.0.6",
48
55
  "@types/semver": "^7.3.10",
49
- "discord.js": "^13.8.1",
56
+ "discord.js": "^14.0.3",
50
57
  "typescript": "^4.7.4"
51
58
  },
52
59
  "peerDependencies": {
53
- "discord.js": "13.8.x"
54
- }
60
+ "discord.js": "14.0.x"
61
+ },
62
+ "packageManager": "yarn@1.22.19"
55
63
  }
@@ -2,52 +2,49 @@
2
2
  # To use env variable as a token just do it like this env:TOKEN_ENV
3
3
  token: TOKEN
4
4
 
5
- # Message command prefix
6
- prefix: '!'
7
-
8
5
 
9
6
  # Commands options
10
7
  commands:
11
8
  messageCommand:
12
9
  # enable message commands
13
10
  enabled: true
11
+ # command prefix
12
+ prefix: '!'
14
13
  # reply when an error occured
15
14
  replyOnError: false
16
15
  # Enable the use of command cooldowns
17
- enableCooldown: false
16
+ enableCooldown: true
18
17
  # Allow executing commands via aliases
19
18
  allowCommandAlias: true
20
19
  # command argument separator
21
20
  commandArgumentSeparator: ' '
21
+ # Overwrite command permissions
22
+ permissions:
23
+ # enable overwriten command permissions
24
+ enabled: false
25
+ commands:
26
+ - command: 'example-command'
27
+ permissions: ['Administrator']
22
28
  interactionCommand:
23
29
  # enable interaction commands
24
30
  enabled: true
25
31
  # reply when an error occured
26
32
  replyOnError: false
27
33
  # Enable the use of command cooldowns
28
- enableCooldown: false
34
+ enableCooldown: true
29
35
  # register interaction commands on bot ready
30
36
  registerCommands: true
31
37
  # set required permissions for interaction commands
32
38
  setRequiredPermissions: true
33
39
  # register commands to specific guild(s) empty to make it global
34
40
  guilds: []
35
-
36
-
37
- # Commands permissions
38
- permissions:
39
- messageCommands:
40
- # enable command permissions
41
- enabled: true
42
- commands:
43
- - command: 'stop'
44
- permissions: ['ADMINISTRATOR']
45
- interactionCommands:
46
- # enable command permissions
47
- enabled: true
48
- commands:
49
- - command: 'stop'
50
- permissions: ['ADMINISTRATOR']
41
+ # Overwrite command permissions
42
+ permissions:
43
+ # enable overwriten command permissions
44
+ enabled: false
45
+ commands:
46
+ - command: 'example-command'
47
+ permissions: ['Administrator']
51
48
 
52
49
 
53
50
  # Ignored channel IDs
@@ -76,13 +73,14 @@ fileLogging:
76
73
  # Client options
77
74
  client:
78
75
  intents:
79
- - 'GUILDS'
80
- - 'GUILD_MEMBERS'
81
- - 'GUILD_MESSAGES'
76
+ - 'Guilds'
77
+ - 'GuildMembers'
78
+ - 'GuildMessages'
79
+ - 'MessageContent'
82
80
 
83
81
  # Bot replies
84
82
  messages:
85
- notEnoughArguments: 'Not enough arguments.'
83
+ missingArguments: 'Not enough arguments.'
86
84
  invalidArguments: 'Invalid argument(s) given.'
87
85
  insufficientBotPerms:
88
86
  content: 'Insufficient bot permissions.'
@@ -1,5 +0,0 @@
1
- import { Config } from './classes/RecipleConfig';
2
- /**
3
- * Check if the channel id is ignored in config file
4
- */
5
- export declare function isIgnoredChannel(channelId: string, ignoredChannelsConfig?: Config["ignoredChannels"]): boolean;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isIgnoredChannel = void 0;
4
- /**
5
- * Check if the channel id is ignored in config file
6
- */
7
- function isIgnoredChannel(channelId, ignoredChannelsConfig) {
8
- if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
9
- return false;
10
- if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
11
- return true;
12
- if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
13
- return true;
14
- return false;
15
- }
16
- exports.isIgnoredChannel = isIgnoredChannel;