Making the Bot come alive
Table of Contents
Episode Overview
- create the bot
- connect it to code
- bring it online
- add out first slash command
Create the Bot
Go to: Discord Developers Portal and login with your discord account
- Click "New Application"

- Give it a name e.g.:
MyBot

- In the side menu click on "Bot" and scroll down to Intents section and enable all 3.

Intents control what events Discord allows your bot to receive.
Invite the Bot
- In the side menu click on "OAuth2" and scroll down to "OAuth2 URL Generator" section.

- In Scopes enable
- "bot"
- "application.commands"

- In Bot Permissions enable
- Send Messages
- Use Slash commands
- Read Message History

- Copy the Generated URL and paste it in your browser to invite your bot to your server.

- The bot has now joined the server and appears offline in the member list

Create the Project
Through the entire tutorial I'll be using Visual Studio Code (VS Code for short) as my code editor.
Create a new folder: discord-bot
Inside the terminal (in VS Code):
A file named "package.json" will be created and shown in this folder.
Inside the terminal:
2 packages called discord.js and dotenv will be installed in your projects folder. You should also see a new folder node_modules.
VERY IMPORTANT
Open package.json and add:
This enables modern JavaScript imports instead of require.
Create files:
src/index.js.env
Token Setup
- In the side menu click on "Bot" then under "Token" click "Reset Token".

Pase this token without quotes after TOKEN in your .env file.
You may also replace APPLICATION_ID with the Client ID
Do the same for SERVER_ID with the ID of the server you invited the bot to.
WarningDO NOT SHARE YOUR TOKEN WITH ANYONE OR THEY WILL BE ABLE TO MANIPULATE AND CONTROL YOUR BOT INSTEAD OF ONLY YOU. You can Reset your tOKEN any time in worst case scenario!
First Bot code
Add this to your index.js file.
Run:
Register Slash Commands
Run Once:
Handle the Command
Back to src/index.js
Restart bot:
Run /ping
Bot replies ✅
Wrap up
Your bot is now alive and responding to slash commands using modern JavaScript modules.
In the next episode we'll turn this into a real scalable command handler so we never end up with messy code later.