Getting Started - TL;DR

circle-info

This is the TL;DR version. If you wish for a long version with more explanations, please see this guide

Create App and Bot Account

  • Create a New Application, and give it a name

  • Click Bot, Add Bot then finally click Yes, do it

  • Visit https://discord.com/oauth2/authorize?client_id=APP_ID&scope=bot , replacing APP_ID with the Application ID from the app page, to add the bot to your server (or ask a server admin to do it for you). If you're wanting slash commands as well, add %20applications.commands to the end of the URL above.

  • Copy your bot's Secret Token and keep it for later

Pre-requisite software

Depending on the operating system you're running the installation will be slightly different.

Once you have this all installed, create a folder for your project and install discord.js:

mkdir mybot cd mybot npm i discord.js

Example Code

The following is a simple ping/pong bot. Save as a text file (e.g. index.js), replacing the string on the last line with the secret bot token you got earlier:

Launching the bot

In your command prompt, from inside the folder where index.js is located, launch it with:

node index.js

If no errors are shown, the bot should join the server(s) you added it to.

Resources

Last updated