Git Product home page Git Product logo

discordbottemplate's Introduction

DiscordBotTemplate

A simple template to get you started with discord.js.

Requirements

  • Node.JS v12 or higher (This particular version uses Node.JS v14.15.1)
  • A sufficient text editor. I suggest Visual Studio Code however Sublime Text and Atom are great alternatives.
  • A Discord account
  • Some knowledge on the discord.js library. If this is your first time, documentation for discord.js can be found here.

Setup

Disclaimer: This is a bare bones setup for a discord bot, and I will not be teaching you how to use the discord.js library. However, I will be teaching you how to use this template for a simple command handler for your projects. For more advanced projects, I suggest using WOKCommands as it has a better command handler system, database intregration and much more.

  1. Clone or install this repository locally to your machine.

This can be done via:

  • git clone https://github.com/ErnieDaTryHard/DiscordBotTemplate.git on the command line (if you have git installed)
  • Through GitHub Desktop
  • Downloaded as a zip from this repository page (be sure to rename the files to not have -master as this can mess up the file system later on)
  1. Install the required dependencies. This can be done by running npm install on the command line in our cloned / downloaded directory.

  2. Create a new application for your discord bot. Visit the Discord Dev Portal to create a new application.

Once created, go to the bot tab and create a new bot. Then copy the bot's token and paste it into the config.json file where it says "paste token here"

Note: DO NOT share your bot token with anyone. Treat it as your password for your bot. If people have your bot token, all progress that you have made into developing your Discord Bot can be destroyed in an instant with API abusers. This can get your discord account banned as the bot is tied with your account.

  1. We need to invite our discord bot to a server in order to start development. To do this, visit the Discord Permissions Calculator and insert your client ID here:

Your client ID can be found in the General Information tab of your application in the Discord Dev Portal.

Next, add all the required permissions your bot needs in order to do what you intend for it to do. If your bot doesn't have sufficient permissions for an action you are trying to perform, then it will throw an error. In our case, we will select only the Administrator permission as we are developing our bot and we want it to be able to achieve anything that is necessary to complete an action. How you choose to setup your permissions when you release your bot publicly is up to you.

Copy the link generated at the bottom and open it in a new tab. This will give you a bot invite, so you can invite it to your testing server.

  1. Let's make sure our bot is functioning. Run node . on the command line in your bot directory to start up your bot. In your testing server you should see your bot going online, which is a good sign. In any of your text channels, type !ping. If the bot responds with pong!, then your bot is succesfully up and running. To shut down your bot, go back to the command line and enter Ctrl + C.

Great! Your bot is now up and running and you can now code your commands with a simple command handler. For guides on the discord.js library use Youtube.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.