Aliases
Make multiple command names for a command

Here we'll be showing you how to make aliases for your commands with AND without a command handler!

Without command handler
With command handler

All you need to do for adding aliases to your commands is adding 1 piece of line to your command code as explained below:

1
bot.Command({
2
name: "help",
3
aliases: ["halp", "helper", "helpme"],
4
code: `
5
Your help code should be here XD
6
`
7
})
Copied!

Let me explain:

By adding aliases: ["halp", "helper", "helpme"], just below the original command name, the help page can now be executed with halp, helper and helpme
Don't forget to add the , at the very end of the aliases string so the code itself can be read by the bot and no errors are thrown!

You can now use aliases with your commands!

This is almost the same for the exception of 1 thing and that will be explained in this guide:

1: Just like the alias method without the command handler, you'll need to add 1 piece of line to your command code as explained below:

1
module.exports = ({
2
name: "help",
3
aliases: ["halp", "helper", "helpme"],
4
code: `
5
Your help code should be here XD
6
`
7
});
Copied!

Below is the only difference between aliases without a command handler:

Keep in mind that below is not the full version of the command handler and is only a portion of it to show what you need to add to the command handler for the bot to see the aliases in the commands ran thru module.exports = ({
For how to set up a command handler, visit the Command Handler guide

2: Add this line of code to your existing command handler in your main file so the bot can see the aliases of each command.

Code to add: aliases: command.aliases,

1
...<= The rest of the data from the handler =>...
2
3
for (const commands of folder) {
4
const command = require(`./commands/${files}/${commands}`)
5
bot.Command({
6
name: command.name,
7
aliases: command.aliases,
8
code: command.code
9
})
Copied!

You can now use aliases with your commands in the command handler!

Credit to Lord Dinonaut#0001 for finding aliases in command handler!
Last modified 1yr ago
Copy link