How to Create a Discord Bot — Complete Beginner's Guide (2025)
Creating a Discord bot is one of the most exciting projects a developer can take on. Whether you want to automate tasks in your Discord server, build a fun game bot, or create a powerful moderation tool, this guide walks you through every step — from registering your application on the Discord Developer Portal to writing your first command.
By the end of this tutorial, you will have a fully working Discord bot that responds to messages. Let's get started.
What is a Discord Bot?
A Discord bot is a type of automated user account that runs on Discord's platform. Bots can respond to commands, manage server roles and channels, play music, send announcements, run games, moderate chat, and much more. They are created using Discord's official API and can be programmed in many languages including JavaScript (discord.js), Python (discord.py), Java (JDA), and others.
Discord bots are used by millions of servers worldwide for tasks like welcome messages, role assignment, music playback, economy systems, moderation, and community engagement.
Step 1: Create a Discord Account
Before creating a bot, you need a Discord account. If you don't have one, visit discord.com and sign up for free. Discord is available on Windows, macOS, Linux, iOS, and Android, as well as in your web browser.
Step 2: Visit the Discord Developer Portal
The Discord Developer Portal is where you create and manage your bot applications. Follow these steps:
- Go to discord.com/developers/applications
- Log in with your Discord account
- Click the "New Application" button in the top-right corner
- Give your application a name (this will be your bot's name)
- Accept the Discord Developer Terms of Service
- Click Create
Your new application is now created. You will see the application page with details like the Application ID (also called Client ID), description, and icon settings.
Step 3: Create a Bot User
After creating the application, you need to turn it into a bot:
- In the left sidebar, click on "Bot"
- Click "Add Bot" and confirm by clicking "Yes, do it!"
- Your bot is now created. You will see the bot's username and a section for the bot token.
- Click "Reset Token" to get your bot's token — keep this secret!
Important: Your bot token is like a password. Never share it publicly or commit it to GitHub. If your token is ever exposed, reset it immediately from the Developer Portal.
Step 4: Configure Bot Permissions and Intents
Privileged Gateway Intents control what events your bot can listen to. For most bots, you will need:
- Server Members Intent — to see member join/leave events and member lists
- Message Content Intent — to read message content (required for prefix commands)
- Presence Intent — to track user presence (online/offline status)
Enable the intents you need in the Bot section of the Developer Portal, then scroll down and save changes.
Step 5: Generate an Invite Link
To add your bot to a Discord server, generate an OAuth2 invite link:
- Go to OAuth2 → URL Generator in the left sidebar
- Under Scopes, check
botandapplications.commands - Under Bot Permissions, select the permissions your bot needs (e.g., Send Messages, Manage Roles, Ban Members)
- Copy the generated URL at the bottom
- Open the URL in your browser and select the server to invite your bot to
Step 6: Set Up Your Development Environment
You will need Node.js (for JavaScript/discord.js) or Python (for discord.py) installed on your computer.
For discord.js:
npm init -y
npm install discord.js
For discord.py:
pip install discord.py
Step 7: Write Your First Bot (discord.js example)
Create a file called index.js and add the following code:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('messageCreate', (message) => {
if (message.author.bot) return;
if (message.content === '!ping') {
message.reply('Pong! 🏓');
}
if (message.content === '!hello') {
message.reply(`Hello, ${message.author.username}!`);
}
});
client.login('YOUR_BOT_TOKEN_HERE');
Run your bot with:
node index.js
Your bot is now running! Type !ping in your server and it will respond with "Pong! 🏓"
Step 8: Keep Your Bot Running 24/7
Running your bot locally means it goes offline when you close your computer. To keep it online 24/7, you need a hosting solution. Popular options include VPS providers like DigitalOcean, Linode, or cloud platforms like Railway, Render, or Heroku alternatives.
Step 9: List Your Bot on dlist.space
Once your bot is ready, you can share it with the world by listing it on dlist.space — the top Discord bot and server discovery platform. Thousands of Discord server owners browse dlist.space every day looking for bots to add to their servers.
Listing your bot on dlist.space is free and takes only a few minutes. Check out our guide on how to add your bot to dlist.space for a step-by-step walkthrough.
Conclusion
Congratulations! You have created your first Discord bot. You've learned how to use the Discord Developer Portal, set up a bot token, configure permissions, and write basic commands. From here, you can expand your bot with more advanced features like slash commands, database integration, music playback, and more.
Happy coding, and welcome to the Discord bot development community!