refactor: Extract interaction handling logic into dedicated ComponentInteractionHandler, AutocompleteHandler, and CommandHandler classes.
This commit is contained in:
21
src/lib/handlers/AutocompleteHandler.ts
Normal file
21
src/lib/handlers/AutocompleteHandler.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { AutocompleteInteraction } from "discord.js";
|
||||
import { AuroraClient } from "@/lib/BotClient";
|
||||
|
||||
/**
|
||||
* Handles autocomplete interactions for slash commands
|
||||
*/
|
||||
export class AutocompleteHandler {
|
||||
static async handle(interaction: AutocompleteInteraction): Promise<void> {
|
||||
const command = AuroraClient.commands.get(interaction.commandName);
|
||||
|
||||
if (!command || !command.autocomplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await command.autocomplete(interaction);
|
||||
} catch (error) {
|
||||
console.error(`Error handling autocomplete for ${interaction.commandName}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user