From 7e6f7b12ae966e3a15a7b809a9ad6bd81b5ba18a Mon Sep 17 00:00:00 2001 From: xHyroM Date: Thu, 24 Aug 2023 16:13:15 +0200 Subject: [PATCH] fix: some type issues in handleAutocomplete --- src/listeners/interaction_create.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/listeners/interaction_create.ts b/src/listeners/interaction_create.ts index bb1a000..aeee99b 100644 --- a/src/listeners/interaction_create.ts +++ b/src/listeners/interaction_create.ts @@ -1,9 +1,9 @@ -import { Events, Interaction, ChatInputCommandInteraction, AutocompleteInteraction } from "discord.js"; +import { Events, Interaction, ChatInputCommandInteraction, AutocompleteInteraction, APIApplicationCommandSubcommandOption, APIApplicationCommandSubcommandGroupOption } from "discord.js"; import { COMMANDS } from "../loaders/commands.ts"; import { defineListener } from "../loaders/listeners.ts"; import { InteractionCommandContext } from "../structs/context/CommandContext.ts"; import { AutocompleteContext } from "../structs/context/AutocompleteContext.ts"; -import { StringOption } from "../structs/Command.ts"; +import { Option, StringOption } from "../structs/Command.ts"; defineListener({ event: Events.InteractionCreate, @@ -42,10 +42,11 @@ async function handleAutocomplete(interaction: AutocompleteInteraction) { let options = command.options; if (interaction.options.getSubcommandGroup(false)) - options = options.find(o => o.name === interaction.options.getSubcommandGroup())?.options; + options = (options.find(o => o.name === interaction.options.getSubcommandGroup()) as APIApplicationCommandSubcommandGroupOption)?.options as Option[]; if (interaction.options.getSubcommand(false)) - options = options.find(o => o.name === interaction.options.getSubcommand())?.options; + options = (options.find(o => o.name === interaction.options.getSubcommand()) as APIApplicationCommandSubcommandOption)?.options as Option[]; + const focused = interaction.options.getFocused(true); const option = options.find(o => o.name === focused.name) as StringOption;