reciple 3.1.4 → 4.0.0-pre.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/bin/index.d.ts CHANGED
@@ -2,7 +2,7 @@ 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';
5
+ export * from './reciple/classes/builders/SlashCommandBuilder';
6
6
  export * from './reciple/classes/builders/MessageCommandBuilder';
7
7
  export * from './reciple/classes/builders/MessageCommandOptionBuilder';
8
8
  export * from './reciple/types/builders';
package/bin/index.js CHANGED
@@ -18,7 +18,7 @@ __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);
21
+ __exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
22
22
  __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
23
23
  __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
24
24
  __exportStar(require("./reciple/types/builders"), exports);
@@ -2,8 +2,8 @@ import { RecipleModule } from '../modules';
2
2
  import { ApplicationCommandBuilder } from '../registerInteractionCommands';
3
3
  import { RecipleCommandBuilder, RecipleCommandBuilderType } from '../types/builders';
4
4
  import { RecipleAddModuleOptions } from '../types/paramOptions';
5
- import { InteractionCommandBuilder, InteractionCommandExecuteData } from './builders/InteractionCommandBuilder';
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,7 +70,7 @@ 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
  /**
@@ -76,8 +79,8 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
76
79
  */
77
80
  addModule(options: RecipleAddModuleOptions): 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
85
  addCommand(command: RecipleCommandBuilder): RecipleClient<Ready>;
83
86
  /**
@@ -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
@@ -107,7 +110,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
107
110
  * @param type Command type
108
111
  */
109
112
  findCommand(command: string, type: RecipleCommandBuilderType.MessageCommand): MessageCommandBuilder | undefined;
110
- findCommand(command: string, type: RecipleCommandBuilderType.InteractionCommand): InteractionCommandBuilder | undefined;
113
+ findCommand(command: string, type: RecipleCommandBuilderType.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
141
  if (command.builder === builders_1.RecipleCommandBuilderType.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.RecipleCommandBuilderType.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
  /**
@@ -244,26 +247,26 @@ class RecipleClient extends discord_js_1.Client {
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.RecipleCommandBuilderType.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;
@@ -278,12 +281,12 @@ 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.RecipleCommandBuilderType.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) {
289
+ else if (this.config.commands.slashCommand.enableCooldown && command.cooldown) {
287
290
  if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.RecipleHaltedCommandReason.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
  }
@@ -318,8 +321,8 @@ 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];
324
+ case builders_1.RecipleCommandBuilderType.SlashCommand:
325
+ return this.commands.slashCommands[command];
323
326
  case builders_1.RecipleCommandBuilderType.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())))
@@ -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.RecipleCommandBuilderType.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.RecipleCommandBuilderType.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
  /**
@@ -0,0 +1,56 @@
1
+ import { RecipleCommandBuilderType } from '../../types/builders';
2
+ import { RecipleHaltedCommandData } 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 = RecipleCommandBuilderType.SlashCommand;
24
+ cooldown: number;
25
+ requiredBotPermissions: PermissionResolvable[];
26
+ requiredMemberPermissions: PermissionResolvable[];
27
+ allowExecuteInDM: boolean;
28
+ halt?: (haltData: RecipleHaltedCommandData<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: RecipleHaltedCommandData<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.RecipleCommandBuilderType.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;
@@ -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.RecipleCommandBuilderType.MessageCommand || command.builder === builders_1.RecipleCommandBuilderType.SlashCommand) {
54
54
  commands.push(command);
55
55
  }
56
56
  }
@@ -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 { RecipleRegisterApplicationCommandsOptions } 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: RecipleRegisterApplicationCommandsOptions): 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 RecipleCommandBuilder = MessageCommandBuilder | SlashCommandBuilder;
7
7
  /**
8
8
  * Reciple command builders execute data
9
9
  */
10
- export declare type RecipleCommandBuildersExecuteData = InteractionCommandExecuteData | MessageCommandExecuteData;
10
+ export declare type RecipleCommandBuildersExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
11
11
  /**
12
12
  * Types of Reciple command builders
13
13
  */
14
14
  export declare enum RecipleCommandBuilderType {
15
15
  MessageCommand = 0,
16
- InteractionCommand = 1
16
+ SlashCommand = 1
17
17
  }
@@ -7,5 +7,5 @@ exports.RecipleCommandBuilderType = void 0;
7
7
  var RecipleCommandBuilderType;
8
8
  (function (RecipleCommandBuilderType) {
9
9
  RecipleCommandBuilderType[RecipleCommandBuilderType["MessageCommand"] = 0] = "MessageCommand";
10
- RecipleCommandBuilderType[RecipleCommandBuilderType["InteractionCommand"] = 1] = "InteractionCommand";
10
+ RecipleCommandBuilderType[RecipleCommandBuilderType["SlashCommand"] = 1] = "SlashCommand";
11
11
  })(RecipleCommandBuilderType = exports.RecipleCommandBuilderType || (exports.RecipleCommandBuilderType = {}));
@@ -1,14 +1,14 @@
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
5
  import { RecipleCommandBuilder } 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>;
9
+ export declare type RecipleHaltedCommandData<Builder extends RecipleCommandBuilder = RecipleCommandBuilder> = RecipleCommandErrorData<Builder> | RecipleCommandCooldownData<Builder> | (Builder extends SlashCommandBuilder ? never : RecipleCommandInvalidArguments<Builder> | RecipleCommandMissingArguments<Builder>) | RecipleCommandMissingMemberPermissions<Builder> | RecipleCommandMissingBotPermissions<Builder>;
10
10
  export interface RecipleCommandHaltBaseData<Builder extends RecipleCommandBuilder> {
11
- executeData: Builder extends InteractionCommandBuilder ? InteractionCommandExecuteData : MessageCommandExecuteData;
11
+ executeData: Builder extends SlashCommandBuilder ? SlashCommandExecuteData : MessageCommandExecuteData;
12
12
  }
13
13
  export interface RecipleCommandErrorData<Builder extends RecipleCommandBuilder> extends RecipleCommandHaltBaseData<Builder> {
14
14
  reason: RecipleHaltedCommandReason.Error;
@@ -10,15 +10,15 @@ export interface RecipleAddModuleOptions {
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 RecipleRegisterApplicationCommandsOptions {
22
22
  /**
23
23
  * Bot client
24
24
  */
@@ -27,7 +27,7 @@ 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[];
@@ -35,5 +35,5 @@ export interface RecipleRegisterInteractionCommandsOptions {
35
35
  export interface RecipleUserHasCommandPermissionsOptions {
36
36
  builder: RecipleCommandBuilder;
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.1",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -22,7 +22,7 @@
22
22
  "clean": "rm -rf 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,7 +58,6 @@
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",
63
62
  "typedoc": "^0.23.9",
64
63
  "typedoc-plugin-discord-types": "^1.0.2",
@@ -67,7 +66,7 @@
67
66
  "typescript": "^4.7.4"
68
67
  },
69
68
  "peerDependencies": {
70
- "discord.js": "14.0.x"
69
+ "discord.js": "^14.0.3"
71
70
  },
72
71
  "packageManager": "yarn@3.2.2"
73
72
  }
@@ -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
- }