Interaction commands
guideSlash commands and right-click context commands, declared by a structure or a builder and pushed to Discord by the script.
An interaction command is registered on Discord and shown by the client itself: a /command in the picker, or an entry in the right-click Apps menu on a user or a message. Discord types and validates its arguments before the bot sees them. You're assumed to have a bot named "my-bot" logged in (see Starting a bot).
slash command ping: description: Pong! trigger: reply with hidden "Pong! (%used slash command%)" on guild ready: update the discord commands (all structured application commands) in event-guild
The structure declares the command and its trigger; the on guild ready block is what puts it on Discord. Nothing reaches Discord on its own, at load, reload or unload.
Structure or builder
Need | Use |
|---|---|
A | |
A | |
An entry in the right-click Apps menu | a context command, structure or builder |
A command matched on typed text, with no Discord registration |
Both forms produce the same command objects and can be pushed in the same call; a structure keeps its own trigger, a builder is answered in the generic on slash command event.
Reading order
- Slash commands: the structure, its path, description, trigger, and what changed from v4.
- Slash options: argument types, choices, autocomplete, typed options.
- Context commands:
user commandandmessage command, their targets. - Command builders: building a command as an object, mixing with structures.
- Registering commands:
update,register,unregister, reload. - Command settings: permissions, contexts, localisation, cooldowns.