Skip to content
/ discord-bot Public template

Template and Framework for Discord Bots built with JavaScript.

License

Notifications You must be signed in to change notification settings

cifrelabs/discord-bot

Repository files navigation

Discord Bot Template

Creating a Discord Bot from scratch can be tedious. We made this template for everyone to easily create and deploy customized discord bots.

Prerequisites

  1. JavaScript
  2. NodeJS and NPM
  3. Node Packages:

Quick Setup

  1. Create a .env file containing the following (use the template provided):
TOKEN = INSERT_BOT_TOKEN
CLIENT_ID = INSERT_CLIENT_ID
  1. Run npm i in the terminal.
  2. Then, run npm start.
  3. Go to your Discord Server where you added your bot, and try to run the command /hello.

Beginner Step-by-step Setup

  1. Go to the Discord Developers Panel and create a new Application.
  2. After creating your app, on the Left Menu Panel, Go to "Bot", and create a new bot.
  3. This will give you a new "Token". Copy it and paste it to your .env file. Do not share this token to anyone.

Adding the Bot to your Discord Server

  1. Again on the Left Menu Panel, Go to "OAuth2" → "URL Generator".
    • Under Scopes, Tick the bot and applications.commands checkboxes.
    • Under Bot Permissions, Tick the Administrator checkbox.
  2. If you scroll down, you will see a Generated URL section. Copy it and paste it to your web browser's address bar. This will allow you to invite your newly created bot to your own Discord Server.

Running the Bot

  1. Run npm start in the terminal.
  2. Go back to your Discord Server where you added your bot, and try to run the command /hello.

Creating a Command

Each command is a separate .js file. All of the commands are located in ./src/commands/. You can use the already-included-sample-command file, hello.js, as a guide. To add choices to your slash command, refer to this documentation.

Reminders

  • We highly suggest to not write your program inside index.js but instead create handlers for listeners for better organization. In our convention, we place these events in the ./src/listeners folder and in the ./src/handlers folder.
  • The .env file and tokens inside it are not meant to be pushed to the remote repository.

About

Template and Framework for Discord Bots built with JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published