Skip to main content

Overview ๐Ÿš€

Next-gen bot development is all about organization, and that's where Robo.js shines! ๐ŸŒŸ

If you're familiar with Next.js, you'll feel right at home. If not, no worriesโ€”Robo.js keeps things simple. All you need to know is how to arrange your files. And that's it. Seriously!

The Robo.js File Structure ๐Ÿ“‚โ€‹

To start with, you'll need a src directory at the root with commands and events directories inside. The command file's name becomes the command name, and the event file's name turns into the triggering event's name.

Here's a basic example of a Robo.js file structure:

โ”œโ”€โ”€ commands/
โ”‚ โ””โ”€โ”€ ping.js
โ””โ”€โ”€ events/
โ””โ”€โ”€ messageCreate.js

Want to go a step further? No problem! You can nest files to create subcommands and grouped events.

โ”œโ”€โ”€ commands/
โ”‚ โ”œโ”€โ”€ ping.js
โ”‚ โ”œโ”€โ”€ ban/
โ”‚ โ”‚ โ””โ”€โ”€ user.js
โ”‚ โ””โ”€โ”€ settings/
โ”‚ โ””โ”€โ”€ update/
โ”‚ โ””โ”€โ”€ something.js
โ””โ”€โ”€ events/
โ”œโ”€โ”€ ready.js
โ””โ”€โ”€ messageCreate/
โ””โ”€โ”€ dm.js
โ””โ”€โ”€ hello.js

Modular Magic ๐Ÿ“ฆโ€‹

For larger Robo projects, modules are your best friends! They allow you to group the same folder structure within modular subfolders. Think of it like having mini Robo projects within your main project. The names of the folders inside "modules/" can be anything you want, as long as what's inside follows the Robo file structure.

โ””โ”€โ”€ modules/
โ”œโ”€โ”€ moderation/
โ”‚ โ”œโ”€โ”€ commands/
โ”‚ โ””โ”€โ”€ events/
โ””โ”€โ”€ fun/
โ”œโ”€โ”€ commands/
โ””โ”€โ”€ events/

For a deeper dive into the world of modules, check out the modules documentation.

Creating Commands ๐Ÿ“œโ€‹

Commands in Robo.js are super straightforward. Just create a file in the commands directory, and the name of the file becomes the name of the command. Easy peasy, right? Plus, Robo.js also takes care of registering them for you. You can even nest commands for those extra spicy subcommands! ๐ŸŒถ๏ธ

Here's how your command file structure might look:


And the ping.js file could be as simple as:

export default () => {
return 'Pong!'

To learn more about commands and their full potential, head over to the commands documentation.

Listening to Events ๐Ÿ“กโ€‹

Just like commands, events in Robo.js follow the same naming convention. Create a file in the events directory, and the name of the file becomes the Discord event you're listening to. But wait, there's more! Events can be stacked for even more control over your bot's responses. ๐Ÿค–

Here's a quick peek at your event file structure:


And the messageCreate.js file could be:

export default (message) => {
if (message.content.includes('hello')) {'Hello there!')

To dive deeper into events, check out the events documentation.

Sage Mode ๐Ÿ”ฎโ€‹

Meet Sage, your new best friend in interaction handling. Sage operates behind the scenes, automatically simplifying interaction handling and providing smart error replies that make debugging a breeze. With Sage, you can focus on what you do best: creating epic bot interactions! โœจ

Do This

Unlock the full power of Sage Mode by visiting the Sage documentation.

Robo.js Logo

MIT ยฉ 2024 Robo.js By WavePlay