import { ApplyOptions } from '@sapphire/decorators';
import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework';
import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Autocomplete
})
export class AutocompleteHandler extends InteractionHandler {
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
return interaction.respond(result);
}
public override parse(interaction: AutocompleteInteraction): Awaitable<Option<ApplicationCommandOptionChoiceData[]>> {
// Only run this interaction for the command with ID '1000000000000000000'
if (interaction.commandId !== '1000000000000000000') return this.none();
return this.some([
{
name: 'a',
value: 'b'
}
]);
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework';
import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Autocomplete
})
export class AutocompleteHandler extends InteractionHandler {
public override async run(interaction: AutocompleteInteraction, result: InteractionHandler.ParseResult<this>) {
return interaction.respond(result);
}
public override parse(interaction: AutocompleteInteraction): Awaitable<Option<ApplicationCommandOptionChoiceData[]>> {
// Only run this interaction for the command with ID '1000000000000000000'
if (interaction.commandId !== '1000000000000000000') return this.none();
return this.some([
{
name: 'a',
value: 'b'
}
]);
}
}