Are you interested in building your own Discord bot?
Download the free starter Discord Bot here!
In this step-by-step guide, we’ll show you how to create a Discord bot. By the end of this guide, you’ll have a fully functional and customizable Discord bot ready to use!
Creating a Discord Bot is a great way to add features to your server. Here are the steps to create a Discord Bot:
Create a Discord Bot
- Log in to your Discord account and go to the Developer Portal.
- Click on “New Application”.
- Give your application a name and click “Create”.
- On the left side menu, click “Bot”.
- Click “Add Bot”.
- Press “View Token”, copy the token that appears and save it somewhere safe.
- On the same page, scroll down a bit and toggle on the Message Content Intent.
- Go to the OAuth2 page and select “URL Generator”.
- Under “Scopes”, check the “bot”.
- Under “Bot Permissions”, select the permissions you want the bot to have.
- Copy the generated URL and open it in your browser.
- Select the server you want to add the bot to and click “Authorize”.
Setting up Node.js and npm
If you do not have Node.js installed yet, proceed to this link to download and install Node.js and npm.
To ensure that you have installed Node.js and npm:
- Open your “terminal” or “command prompt”.
- Run the following commands:
For Node.js: node -v
For npm: npm -v
- Both of them should return the installed version numbers.
Run a Command
- Download the free starter Discord Bot here!
- Extract the zip file into a designated directory.
- Ensure that you have the following files
index.js - the main file where you will write your code for each command
.env - consists of environment variables
package.json - contains project details and its dependencies
- Open the .env using any of your text editor (eg. Notepad, Visual Studio Code).
- Paste your Discord Bot token after the variable below
- Ensure that you have saved the file.
- Open your terminal and navigate to your bot directory using this command: cd <directory>
Example: cd C:\discord_bot\HelloBot
- Enter this terminal command to install all dependencies: npm install
- A folder node_modules, and package-lock.json will be automatically created.
- Enter this terminal command to run your Discord Bot: node index.js
- A message of “Ready: Hello Bot” should be shown in the terminal.
- Open your Discord, and proceed to the server where your bot is located.
- Enter this prefix command in any of the public channels: !hi
- The bot should respond with “hello!”.
We hope this post has been helpful in getting you started with creating your own Discord bot. Thanks for reading!
Contact us via Discord.
Want to get notified when the developer releases new projects?
Check out these socials!
Buy Me a Coffee?
Did you find this application helpful and would like to support me?
Please proceed to this link. Thank you!