js-discord-modularcommand 3.3.0 → 3.3.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.
@@ -4,7 +4,7 @@
4
4
  * @author vicentefelipechile
5
5
  * @description Provides a modular command handler for a Discord bot using Discord.js.
6
6
  */
7
- import { BaseInteraction, CommandInteraction, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
7
+ import { AutocompleteInteraction, BaseInteraction, CommandInteraction, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
8
8
  import { ClientWithCommands } from "./types";
9
9
  /**
10
10
  * @type InteractionHandler
@@ -12,7 +12,7 @@ import { ClientWithCommands } from "./types";
12
12
  * @param interaction The interaction received from Discord.
13
13
  * @returns {Promise<boolean | undefined>} A promise that resolves to `false` to stop the default handler, or `true`/`undefined` to continue.
14
14
  */
15
- type InteractionHandler = (interaction: CommandInteraction | MessageComponentInteraction | ModalSubmitInteraction) => Promise<boolean | undefined>;
15
+ type InteractionHandler = (interaction: CommandInteraction | MessageComponentInteraction | ModalSubmitInteraction | AutocompleteInteraction) => Promise<boolean | undefined>;
16
16
  /**
17
17
  * @description Creates a modular command handler function for the Discord client.
18
18
  * @param {ClientWithCommands} client The Discord client instance with a commands collection.
@@ -98,7 +98,8 @@ function createOptionBuilder(opt, description) {
98
98
  option.setName(opt.name)
99
99
  .setDescription(description)
100
100
  .setRequired(opt.required || false)
101
- .setDescriptionLocalizations(typeof opt.description === 'object' ? opt.description : {});
101
+ .setDescriptionLocalizations(typeof opt.description === 'object' ? opt.description : {})
102
+ .setAutocomplete(opt.autocomplete || false);
102
103
  if (opt.choices && opt.choices.length > 0) {
103
104
  option.addChoices(...opt.choices);
104
105
  }
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @author vicentefelipechile
5
5
  * @description Defines types and interfaces used throughout the modular command framework.
6
6
  */
7
- import { ApplicationCommandOptionType as OptionType, APIApplicationCommandOptionChoice, ChatInputCommandInteraction, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction, CommandInteraction, ButtonInteraction, SlashCommandBuilder, PartialDMChannel, ThreadChannel, GuildChannel, Collection, Message, Locale, Client, User, Role, APIRole, BaseChannel, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandNumberOption, SlashCommandStringOption, SlashCommandUserOption, SlashCommandRoleOption, SlashCommandIntegerOption } from "discord.js";
7
+ import { ApplicationCommandOptionType as OptionType, APIApplicationCommandOptionChoice, ChatInputCommandInteraction, MessageComponentInteraction, StringSelectMenuInteraction, ModalSubmitInteraction, CommandInteraction, ButtonInteraction, SlashCommandBuilder, PartialDMChannel, ThreadChannel, GuildChannel, Collection, Message, Locale, Client, User, Role, APIRole, BaseChannel, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandNumberOption, SlashCommandStringOption, SlashCommandUserOption, SlashCommandRoleOption, SlashCommandIntegerOption } from "discord.js";
8
8
  import ModularCommand from "./modularcommand";
9
9
  /**
10
10
  * @interface CommandOption
@@ -21,6 +21,8 @@ export interface CommandOption {
21
21
  required?: boolean;
22
22
  /** An array of predefined choices the user can select from. */
23
23
  choices?: APIApplicationCommandOptionChoice[];
24
+ /** Defines if the option should be autocompleted. */
25
+ autocomplete?: boolean;
24
26
  }
25
27
  /**
26
28
  * @interface SubCommand
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-discord-modularcommand",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "discord",