ESN Docs

Docs › Discord bots

Your first Discord bot: a 5-part Python course

1 min readUpdated Nov 3, 2026

A step-by-step course to build a Discord bot in Python 3.12 with discord.py 2: bot account, slash commands, embeds, buttons, cogs, a SQLite points system and 24/7 hosting.

New video: Code your first Discord bot in Python, an 18-minute beginner tutorial with the full code, from installing Python to hosting the bot 24/7. Watch on YouTube.

This course takes you from nothing to a working Discord bot that runs 24/7. You'll write real Python, not copy a template you don't understand. Each part takes 5 to 10 minutes and ends with something that works.

What you'll build #

A bot with slash commands: /ping, /roll, /userinfo (with an embed), /clicker (with a button), and a points system (/daily, /points, /leaderboard) that saves to a database. At the end it runs on a server instead of your computer.

The 5 parts #

PartWhat you doTime
1. Create the bot accountMake an application in the Discord Developer Portal, get the token and invite the bot to a test server.5 min
2. Hello worldInstall Python 3.12 and discord.py, keep the token in .env, and add a /ping slash command.7 min
3. Real commandsOptions, embeds, a button, cooldowns, an error handler, and cogs to keep code tidy.8 min
4. Saving dataA points and leaderboard system stored in SQLite with aiosqlite.8 min
5. Online 24/7Upload the bot to ESN Hosting, set the start file and token, add a restart schedule and backups.7 min

What you need #

  • A computer with Windows, macOS or Linux.
  • A Discord account and a server you own to test in (an empty one is perfect).
  • No paid tools for Parts 1 to 4. Every library in this course is open source.
  • Basic Python helps (variables, functions, if), but every new idea is explained.

Versions used #

Python 3.12 and discord.py 2.x. All code in this course was checked on Python 3.12 with discord.py 2.7. Older tutorials use !prefix commands and the message content intent. This course uses slash commands, which Discord recommends and which need no privileged intents.

Start Part 1: Create the bot account →

FAQ #

Do I need to know Python already?

It helps to know the basics (variables, functions, if statements). The course explains each new idea, like async functions and decorators, when it first appears.

Why discord.py and not discord.js?

Both are good. This course uses Python because it reads like plain English for beginners. If you prefer JavaScript, see discord.py vs discord.js.

Will my bot stay online when I close my laptop?

Not while it runs on your computer. Part 5 moves it to a server so it stays online 24/7.

Want your bot online 24/7? Part 5 shows how to run it on ESN Hosting, with bot hosting from $0.50/month. Read Part 5 or see bot plans.

Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.