LogoRobo.js
TemplatesDiscord bots

Starter (TypeScript)

A basic TypeScript Discord bot template using Robo.js.

Starter (TypeScript)

Welcome to your fresh Robo.js project!

Build, deploy, and maintain your Discord bots with ease. With Robo.js as your guide, you'll experience a seamless, file-based setup, an integrated database, TypeScript support, and a multitude of plugin-powered skills to unlock along the way.

Getting Started

Create a project with this template:

npx create-robo@next <project-name> --template discord-bots/starter-ts

Then navigate into your project directory:

cd <project-name>

Run development mode:

npm run dev

Development

Creating a Slash Command is as easy as creating files.

ping.ts/ping
Quote.tsMessage right-click
ready.ts
robo.mjsMain config
.env

Let's say you want a new /hello command. Just create a file in the /src/commands directory named hello.ts and export a default function that returns something.

/src/commands/hello.ts
export default (interaction) => {
	interaction.reply('Hello World!')
}
/src/commands/hello.js
export default (interaction) => {
	interaction.reply('Hello World!')
}

Your /hello command is now ready to use! Robo.js takes care of registration for you.

Ever clicked on an avatar or message and seen an Apps section? Those are Context Commands!

Create a file in /src/context/message named after the command. For example, Quote.ts.

/src/context/message/Quote.ts
export default (interaction, message) => {
	interaction.reply(`${message.author} said:\n\n> ${message.content}`)
}
/src/context/message/Quote.js
export default (interaction, message) => {
	interaction.reply(`${message.author} said:\n\n> ${message.content}`)
}

Debugging

Discord Bots made with Robo.js come with a built-in Debugger.

Whenever your bot crashes in development mode, the debugger shows an interactive error message - all within Discord!

You even get /dev Subcommands for quick access to logs, system info, and more. Just set your test server's ID as an environment variable called DISCORD_GUILD_ID.

Client Configuration

Robo.js manages your Discord.js Client instance via the @robojs/discordjs plugin. Use getClient() to access it anywhere in your project.

import { getClient } from '@robojs/discordjs'

export default () => {
	const client = getClient()
	return `My name is ${client.user.username}`
}
import { getClient } from '@robojs/discordjs'

export default () => {
	const client = getClient()
	return `My name is ${client.user.username}`
}

Intents or other configurations can be set in the config/plugins/robojs/discordjs.mjs file.

/config/plugins/robojs/discordjs.mjs
export default {
	clientOptions: {
		intents: ['Guilds', 'GuildMessages']
	}
}

Robo Ecosystem

By building with Robo.js, you gain access to a growing ecosystem of plugins, templates, and tools. Robo Plugins are special. They can add features with one command.

npx robo add @robojs/ai@next @robojs/moderation@next

Plugins integrate seamlessly thanks to the Robo File Structure. What's more, anyone can create a plugin.

Hosting

Hosting your project keeps it running 24/7. No need to keep your computer on at all times, or worry about your Internet connection.

You can host on any platform that supports Node.js, or run robo deploy to host on RoboPlay - a hosting platform optimized for Robo.js.

npm run deploy

Learn More

On this page