Skip to content
How to set up a Discord Bot using node.js and
Profile icon

Creating your Discord Bot:

First thing you want to do is, go to
then, add an application.
Once your application is created, go to the bot tab on the right, and create a bot.
Go back to the main page of your application and copy the client id and put it in the link below where is says "INSERT_CLIENT_ID_HERE".
Once you have invited the bot to your server, go back to your bot's page, go to the bot tab and copy your token.

Coding your Discord Bot

Create a node.js page; once that is done, go to index.js, then copy this code below and paste it in index.js:

const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log('Logged in!'); }); client.on('message', msg => { if (msg.content === 'ping') { msg.reply('Pong!'); } }); client.login('YOUR_TOKEN_HERE');

paste your token where is says "YOUR_TOKEN_HERE".

Installing Discord.js
Go to the shell next to your code and type
npm i discord.js
once that is done, run your bot! when you type "ping" in Discord, the bot will respond with Pong!

You are viewing a single comment. View All
Profile icon