Creating a simple Discord bot in Python is easier than you think. In this quick guide, you’ll learn how to:
Developer Mode in DiscordDiscord Developer Portaldiscord.py!ping commandLet’s get started!
To interact with Discord’s backend (like copying channel or server IDs), you’ll need Developer Mode enabled.

Now you can right-click messages, channels, users, etc., and copy their IDs.PingBot), and hit Create.

name, pfp and banner for your bot


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

botapplications.commands (this is optional if you don’t want slash commands or user commands in server)

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)

You’ll need Python 3.8+ and the discord.py library.
discord.pypip install -U discord.pybot.pyHere’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).
python bot.pyIf 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!
You’ve just built your first Discord bot using Python! From here, you can:
on_message, on_member_join)