#Autocomplete Error!
31 messages · Page 1 of 1 (latest)
You didn’t add an autocomplete function to that commands exports
i did
Error disagrees
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName('akinator')
.setDescription('Play Akinator Game.')
.setDMPermission(true)
.addStringOption(option =>
option.setName(`language`)
.setDescription(`In Which Language You Want To Play Akinator`)
.setRequired(true)
.setAutocomplete(true)),
async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused();
const choices = ['Popular Topics: Threads', 'Sharding: Getting started', 'Library: Voice Connections', 'Interactions: Replying to slash commands', 'Popular Topics: Embed preview'];
const filtered = choices.filter(choice => choice.includes(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
},
usage: 'akinator',
category: 'akinator',
permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
});
}
async run(client, interaction) {
}
};```
You added it to the object you pass to the superclass‘s constructor. Not to the class…
Do what I said you didn’t do instead of what you did do
It needs to be a function/method of the class
Kk
Like This???
module.exports = class Akinator extends Command {
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName('akinator')
.setDescription('Play Akinator Game.')
.setDMPermission(true)
.addStringOption(option =>
option.setName(`language`)
.setDescription(`In Which Language You Want To Play Akinator`)
.setRequired(true)
.setAutocomplete(true)),
usage: 'akinator',
category: 'akinator',
permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
});
}
async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused();
const choices = ['Popular Topics: Threads', 'Sharding: Getting started', 'Library: Voice Connections', 'Interactions: Replying to slash commands', 'Popular Topics: Embed preview'];
const filtered = choices.filter(choice => choice.includes(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
}
async run(client, interaction) {
// Your command logic goes here
}
};
@wraith gust
No need to ping me again and again. We are the only two people in this post atm. Have patience
kk
And you can also check yourself by running, no need to ask me when you already have node to answer that question for you
not working above one
Any errors?
Yup Same Error
console.log(command) before your command.autocomplete call then
kk
name: 'akinator',
description: 'Play Akinator Game.',
options: [
{
choices: undefined,
autocomplete: true,
type: 3,
name: 'language',
name_localizations: undefined,
description: 'In Which Language You Want To Play Akinator',
description_localizations: undefined,
required: true,
max_length: undefined,
min_length: undefined
}
],
defaultPermission: undefined,
contextDescription: null,
usage: 'akinator',
category: 'akinator',
permissions: [ 'Use Application Commands', 'Send Messages', 'Embed Links' ],
run: [AsyncFunction: run]
}```
You didn’t seem to have saved or your Command class does some magic stuff to add that run there but not the autocomplete
But I get the feeling you didn’t write that command class yourself but instead either use a framework or followed a tutorial. So ask whoever maintains that how to add autocomplete correctly in there
yes
constructor(client, meta = {}) {
this.client = client;
this.data = meta.data;
this.contextDescription = meta.contextDescription || null;
this.usage = meta.usage || this.name;
this.category = meta.category || 'Info';
this.permissions = meta.permissions || ['Use Application Commands', 'Send Messages', 'Embed Links'];
}
async run() {
throw new Error(`The Slash Command "${this.name}" does not provide a run method.`);
}
};```
Command Class
can you help me now
@wraith gust
👆you seriously need to learn patience
Slash Commands: Autocomplete