Find us on social media
Create a Discord bot from scratch
Register your app in the Discord Developer Portal, create a bot user, get the token and invite it to your server with proper permissions.
Introduction
Before deploying a bot you need to create it in the Discord portal. This guide walks you through from application creation to having the bot online in your server.
Step 1: Create the application
- Go to Discord Developer Portal
- Click New Application
- Choose a name for your application (you can change it later)
- Accept the terms and click Create
Step 2: Create the bot user
- In the sidebar, go to Bot
- Click Add Bot → Yes, do it!
- Customize the bot's name and avatar
Step 3: Configure intents
Intents determine which events your bot receives:
✅ Presence Intent — if you need to see user status
✅ Server Members Intent — if you need member events
✅ Message Content Intent — if you read message contentOnly enable the ones your bot actually needs to respect user privacy.
Step 4: Get the token
- In the Bot section, click Reset Token
- Copy the token and store it securely
# Store it in a .env file
echo 'DISCORD_TOKEN=your_token_here' > .envImportant: Never share or commit the token to Git. If it leaks, regenerate it immediately.
Step 5: Generate the invite URL
- Go to OAuth2 → URL Generator
- Under Scopes, select:
botapplications.commands(for slash commands)
- Under Bot Permissions, choose the required permissions:
Common permissions:
- Send Messages
- Embed Links
- Attach Files
- Read Message History
- Use Slash Commands
- Manage Messages (for moderation)
- Manage Roles (for role systems)- Copy the generated URL and open it in your browser
- Select the server where you want to add the bot
Step 6: Verify the invitation
Once invited, the bot appears offline in your server. To bring it online you need to run the code that connects with the token.
Minimal example with discord.js:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
client.once('ready', () => {
console.log(`Bot connected as ${client.user.tag}`);
});
client.login(process.env.DISCORD_TOKEN);Permissions calculator
Use the official calculator to generate the permissions integer:
https://discordapi.com/permissions.htmlOr calculate it manually by combining flags with bitwise OR.
Recommendations
- Create separate applications for development and production
- Use a test server to test before deploying
- Enable 2FA on your developer account
- Review permissions periodically and remove unused ones