Skip to content

A basic bot template with Commands Handler and Events Handler

License

Notifications You must be signed in to change notification settings

ItzShubhamDev/Discord-Bot-Template

Repository files navigation

Discord.Js Bot Template

A basic bot template with Commands Handler and Events Handler

Begin

Clone the project

  git clone https://github.com/ItzShubhamDev/Discord-Bot-Template.git

Go to the project directory

  cd Discord-Bot-Template

Install dependencies

  npm install

or

  yarn install

Register commands

  node register.js

Start bot

  node .

Environment Variables

To run the bot, you will need to set the following environment variables to your .env file

TOKEN=yourtokenhere

Config

clientId: "0000000000000000000" # Your Discord Bot ID
intents: "00000" # Use https://ziad87.net/intents/ to get your intents

Adding Own Commands

Inside commands folder, create a new folder or use the info foler.

Inside the folder create your own command.js file.

And use the following format

const { SlashCommandBuilder } = require('discord.js');
module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Sends the bot\'s ping.'),
    async execute(interaction) {
        await interaction.reply(`Pong! ${interaction.client.ws.ping}ms`);
    }
};

Adding Own Events

Inside events folder, create a new folder or use the bot or interaction foler.

Inside the folder create your own event.js file.

And use the following format

const { Events } = require('discord.js');

module.exports = {
    name: Events.ClientReady,
    once: true,
    async execute(client) {
        console.log(`[INFO] Logged in as ${client.user.tag}!`);
    }
}

More Information

For information about Discord.Js, use these websites

DiscordJs.Guide

Discord.Js.Org

About

A basic bot template with Commands Handler and Events Handler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published