Creating a Discord bot in 2025

Tue, May 6, 2025 - 3 min read

đź›  How to Make a Discord Bot in Python (3-Minute Guide)

Creating a simple Discord bot in Python is easier than you think. In this quick guide, you’ll learn how to:

  • Enable Developer Mode in Discord
  • Create a bot in the Discord Developer Portal
  • Write a simple bot using discord.py
  • Make a basic !ping command

Let’s get started!


📌 Step 1: Enable Developer Mode in Discord

To interact with Discord’s backend (like copying channel or server IDs), you’ll need Developer Mode enabled.

  1. Open Discord
  2. Go to User Settings → Advanced advanced
  3. Toggle Developer Mode to ON. developer mode Now you can right-click messages, channels, users, etc., and copy their IDs.

🤖 Step 2: Create a Bot on Discord

  1. Go to the Discord Developer Portal
  2. Click “New Application”, give it a name (e.g. PingBot), and hit Create. application
  3. In the sidebar, click “Bot”, Here you can set the name, pfp and banner for your bot bot
  4. Click on “Reset Token” → “Yes, do it! to reset your bot token token

Once reset, store it somewhere. You will need it in future.

NOTE: Tokens are secret keys and a way for you to login to your bot, don’t share it with anyone or they can get access to your bot and cause some harms.


đź”— Step 3: Invite Your Bot to a Server

  1. In the Developer Portal, go to OAuth2 → OAuth2 URL Generator. oauth
  2. Select scopes:
    • âś… bot
    • âś… applications.commands (this is optional if you don’t want slash commands or user commands in server) scope
  3. Under Bot Permissions, check:
    • âś… Administrator (it is a dangerous permission to grant but you should be fine if you are having a private bot and you keep the token safe) perms
  4. Copy the generated URL and open it in your browser.
  5. Select your server and click Authorize.

đź§Ş Step 4: Set Up Your Python Environment

You’ll need Python 3.8+ and the discord.py library.

  1. Install discord.py
pip install -U discord.py
  1. Create a new Python file, e.g., bot.py

đź’ˇ Step 5: Write Your First Discord Bot

Here’s a simple bot that responds to !ping with “Pong!”:

import discord
from discord.ext import commands
 
intents = discord.Intents.default()
intents.message_content = True  # Required for reading message content
 
bot = commands.Bot(command_prefix='!', intents=intents)
 
@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name}!')
 
@bot.command()
async def ping(ctx):
    await ctx.send('Pong!')
 
bot.run('YOUR_BOT_TOKEN_HERE')

đź”’ Replace YOUR_BOT_TOKEN_HERE with your actual token (from Step 2).


🚀 Step 6: Run Your Bot

  • In your terminal:
python bot.py

If all goes well, you’ll see:

Logged in as PingBot!

Now go to your Discord server and type !ping. Your bot should reply with:

Pong!

✅ That’s It!

You’ve just built your first Discord bot using Python! From here, you can:

  • Add more commands
  • Use embeds, reactions, buttons, or slash commands
  • Explore event listeners (e.g., on_message, on_member_join)

đź”— Useful Resources