Getting Started

Creating the base framework for our bot, as well as setting up discord.js and such.

Before we get started, I'm making the assumption you already have node.js and such installed, and that you know how to use discord.js basically.

If you don't, go read this, as that goes outside the scope of this guide.

"The basics"

Alright, skipping the npm i discord.js and such, here's the quick, base code we'll be using to develop this reaction guide bot off:

const Discord = require('discord.js');
const config = require('./config.json');

const client = new Discord.Client();

// pages

// the reaction logic will be here

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag} (ID ${client.user.id})`);
});

client.on('message', async (msg) => {
    if (!msg.content.toLowerCase().startsWith(config.prefix) || msg.author.bot) return;

    const args = msg.content.slice(prefix.length).split(/ +/g);
    const command = args.shift().toLowerCase();
    
    if (command == 'help') {
        // our help command will be here
    }
});

client.login(config.token);

And for the config.json..

{
    "token": "your amazing token here",
    "prefix": "!"
}

Great. The three comments left will be where we create the logic and start for our command, but this will be split into a couple sections for readability.

Now, let's go to the next part, making the command.

Last updated

Was this helpful?