Command Handling
A consistent command pattern (aliases, validations, and predictable replies).
You already have a dispatcher in messageCreate, but the real quality of a music bot comes from having consistent command behavior.
This page sets a simple standard:
- one file per command
- optional aliases
- predictable validations (same voice channel, player exists, etc.)
- clean error handling
The command shape
A typical command module looks like this:
Registering aliases (recommended)
When loading commands, register both the command name and its aliases into the same Collection.
With this approach, client.commands.get('play') and client.commands.get('p') return the same module.
Music command validations you should repeat on purpose
A good music command almost always checks:
- Is the user in a voice channel?
- Is there an active player for this guild?
- Is the user in the same voice channel as the player?
- Is there a current track (when needed)?
This isn’t “boilerplate to avoid” — it’s protection against the most common support questions.
Consistency beats cleverness. Users learn quickly when commands always behave the same way.