Discord Bots
A Discord bot is an automated program that runs inside Discord servers, responding to commands, reacting to events, and automating tasks. Robo.js handles command registration, event routing, and gateway connections so you can focus on your bot's logic.
The @robojs/discordjs plugin provides file-based routing (your file names and folder structure automatically become commands and event handlers) on top of Discord.js. Drop a file in src/commands/ and it becomes a slash command. Add a file in src/events/ and it handles a gateway event. No boilerplate setup required.
These guides cover common bot-building patterns. For the complete plugin API reference including all config fields, utility functions, and advanced features, see the @robojs/discordjs plugin documentation.
Here's a complete /hello command in one file:
export default () => {
return 'Hello, world!'
}export default () => {
return 'Hello, world!'
}That's it — Robo.js registers the command and handles the reply automatically.
A Discord server showing a user typing the /hello slash command and the bot replying with 'Hello, world!' in a text channel, demonstrating Robo.js file-based command routing
Quick Start
Create a new bot project:
npx create-robo@next my-botSelect the bot kit when prompted. Alternatively, add the plugin to an existing Robo project:
npx robo add @robojs/discordjs@nextWhat the Plugin Provides
| Feature | Description |
|---|---|
| Slash commands | File-based routing in /src/commands |
| Events | Gateway event handlers in /src/events |
| Context menus | User and message commands in /src/context |
| Middleware | Intercept command and event execution |
| Sage mode | Automatic reply handling — return a value and Robo.js sends it as the reply |
| Intent inference | Auto-detects which gateway events your bot needs based on registered handlers |
| /dev command | Built-in debugging command for inspecting state |
| Namespace controllers | Programmatic access to registered commands, events, and middleware |
Terminal output of a Robo.js bot starting in development mode, showing the build step completing, commands being registered, and the bot logging in with its Discord tag
