Autocomplete Error!

CommandHandler
module.exports = class Command {
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 autocomplete() {
throw new Error(`The Slash Command ${this.name} Doesn't Have Any Autocomplete Method.`);
}
async run() {
throw new Error(`The Slash Command ${this.name} Doesn't Have Any Run Method.`);
}
};
module.exports = class Command {
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 autocomplete() {
throw new Error(`The Slash Command ${this.name} Doesn't Have Any Autocomplete Method.`);
}
async run() {
throw new Error(`The Slash Command ${this.name} Doesn't Have Any Run Method.`);
}
};
Command
const Command = require('../../structures/CommandClass');

module.exports = class Akinator extends Command {
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName('akinator')
.setDescription('akinator.')
.setDMPermission(true)
.addStringOption(option =>
option.setName(`language`)
.setDescription(`option`)
.setRequired(true)
.setAutocomplete(true)),
usage: 'akinator',
category: 'akinator',
permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
});
}
async autocomplete(client, 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.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
}
async run(client, interaction) {
// Your run logic here
}
};
const Command = require('../../structures/CommandClass');

module.exports = class Akinator extends Command {
constructor(client) {
super(client, {
data: new SlashCommandBuilder()
.setName('akinator')
.setDescription('akinator.')
.setDMPermission(true)
.addStringOption(option =>
option.setName(`language`)
.setDescription(`option`)
.setRequired(true)
.setAutocomplete(true)),
usage: 'akinator',
category: 'akinator',
permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
});
}
async autocomplete(client, 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.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
}
async run(client, interaction) {
// Your run logic here
}
};
2 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Professor
Professor12mo ago
error
TypeError: command.autocomplete is not a function
TypeError: command.autocomplete is not a function