Ready

All about your Ready Event

This listener will be executed whenever your bot starts, or is online.

Now with CommandKit, our events follow the same naming convention as Discord.js, so we need to do the following:

  1. Open your events directory

  2. Inside this directory, create a new folder called ready, as this is the name that Discord.js uses.

  3. Inside the ready folder, create a new JavaScript file. For this sake, we will call this file on-ready.js.

  4. Open this file in your preferred code editor.

We are now ready to write our code inside the on-ready.js file, so open this file and the first we need to do is export a function, as this is how CommandKit finds events to listen to.

So add the following structure:

module.exports = (client) => {};

Now inside the curly braces ({}) we can start writing our code.

The first thing I like to do is console log when the bot becomes online, so:

module.exports = (client) => {
  console.log(`✅ ${client.user.username} is now online.`);
};

We add the console.log() inside this to execute whenever our bot is ready, and ${client.user.username} will insert our bots username, minus its 4 digit tag (#0000).

We can finally restart our bot, so press Ctrl+C in your terminal, then we can type node source/index.js to start our main bot file with Node.js. Don't worry, CommandKit will automatically call our On Ready event when the bot starts.

Interested in adding custom statuses to your bot? Check out Custom Statuses

Custom Statuses

Last updated