DEV Community

Ty
Ty

Posted on

First Steps of discord bots

So today, I've decided to enter the realm of creating a discord bot. For those who are unfamiliar with discord. It's basically another version of slack which you can communicate with people around the world and even voice chat.

I decided on creating a discord bot just to have fun and see what I can do in order to help my daily life. Maybe make it have eval command for my personal use.

But as of right now, I want to note on the process of just even putting the discord bot online.

First, we need to create our bot on the discord developer site which is located here

Create your bot and get your token. Make sure no one knows the token and don't accidentally upload it to github!

Next, I use visual studio code in order to create my bot, but lets create a config.json and add in our bot token variable!
It should look something like

"BOT_TOKEN": "BOT TOKEN"

Make sure to also use npm init to create your package.json

afterwards use npm install discord.js. This will install discords api.

Last step in order for your discord bot to go online, you'll need to make a index.js with a few line of code

The code should look something like this

const Discord = require("discord.js");
const config = require("./config.json");
const client = new Discord.Client();

client.login(config.BOT_TOKEN);
Enter fullscreen mode Exit fullscreen mode

Now test it by running node index.js!

Top comments (0)