import { Interaction } from 'discord.js'; import { slashCommands } from './SlashHandler'; export const autoCompletes = slashCommands.filter( (command) => command.autoComplete ); // Auto load commands from SlashHandler but only include them if they have an autocomplete function export const handleAutoComplete = async ( interaction: Interaction ): Promise => { if (!interaction.isAutocomplete()) return; for (const cmd of autoCompletes) { if (!cmd.autoComplete) return; // Type guard if (interaction.commandName == cmd.data.name) { await cmd.autoComplete(interaction); } } };