How do I use autocompleteRun on subcommands?

^ As the title says. I can't seem to figure out how subcommands can have autocompleteRun implemented. I'm not too worried about duplicates, since there is only one subcommand that uses autocomplete.
Solution:
Doesn't matter. You still just do ```ts public override autocompleteRun(interaction: AutocompleteInteraction) { const subcommand = interaction.options.getSubcommand(); if (subcommand.name === 'the subcommand with autocomplete') {...
Jump to solution
4 Replies
thad
thadOP2y ago
Yeah, but that's for an InteractionHandler, right? Is it possible to use autocompleteRun in a subcommand class without creating a separate InteractionHandler in a different file?
Solution
Favna
Favna2y ago
Doesn't matter. You still just do
public override autocompleteRun(interaction: AutocompleteInteraction) {
const subcommand = interaction.options.getSubcommand();
if (subcommand.name === 'the subcommand with autocomplete') {
if (interaction.options.getFocused() === 'the option with subcommand') {
// do stuff for the specific option
}
}
}
public override autocompleteRun(interaction: AutocompleteInteraction) {
const subcommand = interaction.options.getSubcommand();
if (subcommand.name === 'the subcommand with autocomplete') {
if (interaction.options.getFocused() === 'the option with subcommand') {
// do stuff for the specific option
}
}
}
thad
thadOP2y ago
Ah, ok, that works - thanks

Did you find this page helpful?