Skip to content
Advertisement

Discord.js command handler aliases (discord.js v13)

i want to set a command handler aliases, but the bot is doesn’t response.

in ping.js ===

module.exports = {
name: 'ping',
aliases: ['pong'],
execute(message, client) {
    message.reply('pong!')
    }
}

How i can set?

Advertisement

Answer

You would want to make certain changes in your command handler as well! the suitable changes you need to make would be:

  • Making it in your execute function so it can find and execute aliases too!
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
command.execute(message,client); 

Your definitions of command and commandName may vary so I suggest refering to your own code and making suitable changes rather than copy pasting.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement