LogoRobo.js

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:

src/commands/hello.ts
export default () => {
	return 'Hello, world!'
}
src/commands/hello.js
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

FocusThe slash command input and the bot's reply messageZoom100%NotesShow a real Discord text channel. The user has typed /hello in the command picker and pressed Enter. The bot has replied with 'Hello, world!' directly below. Keep the interface clean with just one exchange visible.

Quick Start

Create a new bot project:

npx create-robo@next my-bot

Select the bot kit when prompted. Alternatively, add the plugin to an existing Robo project:

npx robo add @robojs/discordjs@next

What the Plugin Provides

FeatureDescription
Slash commandsFile-based routing in /src/commands
EventsGateway event handlers in /src/events
Context menusUser and message commands in /src/context
MiddlewareIntercept command and event execution
Sage modeAutomatic reply handling — return a value and Robo.js sends it as the reply
Intent inferenceAuto-detects which gateway events your bot needs based on registered handlers
/dev commandBuilt-in debugging command for inspecting state
Namespace controllersProgrammatic 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

FocusThe terminal output showing successful startup and loginZoom100%NotesRun npx robo dev with a configured bot project. Capture the terminal showing the build output, command registration summary, and the 'Logged in as BotName#1234' line. Use a dark terminal theme.

Next Steps

On this page