In this guide, you’ll create a simple Discord bot using Python. By the end, your bot will be online in your server and able to respond to a basic command.
for this project i thought i would be best to make a copy and paste version to avoid any issues and make the whole thing faster for you, Bellow is the link to the github repo so you can do just that, copy and paste into a file on you desktop called discord bot, you will need it for this project.
GitHub repo: how-to-make-a-discord-bot-using-python
Make sure you have the following installed, set up, and ready before you begin. These tools and accounts are required to create, run, and test your Discord bot properly.
You will need a working installation of Python (version 3.10 or newer). Python is the programming language your bot will be written in, and it must be installed on your system so you can run your bot from the terminal.
You will also need a code editor or IDE to write your bot’s code. This guide recommends Visual Studio Code because it is free, lightweight, and includes a built‑in terminal, extensions, and tools that make Python development easier.
A Discord account is required, along with Developer Mode enabled. Developer Mode allows you to access the Discord Developer Portal, create your bot, and retrieve your bot token.
You must also have a Discord server where you can invite and test your bot. This can be a server you created yourself or any server where you have permission to add bots.
Finally, you will need to install a few Python dependencies that your bot relies on.
These include discord.py for interacting with Discord and python-dotenv for loading your bot token securely from a .env file.
Once all of these prerequisites are installed and ready, you will have everything you need to begin building your Discord bot.
Download Python:https://www.python.org/downloads
Important:During installation tick Add Python to PATH.
You will need to download the dependencies (extra Python packages) that your Discord bot requires in order to run. These are not included with Python by default, so we install them separately.
Inside your project folder, create a file called requirements.txt and add the following:
discord.py
python-dotenv
These two packages are essential:
discord.py — the main library that allows Python to communicate with Discord.
python-dotenv — lets your bot safely load your token from a .env file.
Once the file is created, install everything by running this command in your terminal:
pip install -r requirements.txt
After installation finishes, your environment will be fully ready to run the bot.
If you prefer not to use a requirements.txt file, you can install the required packages directly from your terminal.
This method installs the same dependencies but does not create a requirements file. It’s a quick option if you just want to get started without extra setup.
Windows installation method:
Open Command Prompt or PowerShell inside your project folder and install the required packages directly with:
pip install discord.py
pip install python-dotenv
This installs the same dependencies without needing a requirements.txt file.
macOS installation method:
Open Terminal and navigate to your project folder, then run the following commands:
pip3 install discord.py
pip3 install python-dotenv
macOS often uses pip3 instead of pip, depending on your Python installation.
Linux installation method:
Open your terminal, navigate to your project directory, and install the dependencies with:
pip3 install discord.py
pip3 install python-dotenv
Most Linux distributions use pip3 for Python 3 packages, so this is the recommended command.
This guide recommends using Visual Studio Code (VS Code) because it’s free, lightweight, and works extremely well with Python projects. It also includes a built‑in terminal, extensions, and tools that make writing and running your bot much easier.
Download VS Code here:https://code.visualstudio.com/
Once installed, it’s recommended to add the following extensions:
Python (by Microsoft) — adds Python support, linting, debugging, and IntelliSense.
Pylance — improves code suggestions and error checking.
PyCharm — a full Python IDE with powerful tools (Community Edition is free).
Thonny — very beginner‑friendly and simple.
Sublime Text — lightweight and fast, but requires manual setup.
Notepad++ — works in a pinch, but lacks advanced features.
Any editor will work, but VS Code provides the best balance of simplicity and power for new developers.
You will need a Discord account with Developer Mode enabled. This is required so you can access the Discord Developer Portal, create your bot, and retrieve your bot token.
To enable Developer Mode:
Open User Settings → scroll down to Advanced → toggle on Developer Mode.
You will also need a Discord server where you can test your bot. This can be a server you created yourself, or any server where you have permission to invite bots.
If you don’t have a server yet, you can create one easily:
Click the + icon in the Discord server list → choose Create My Own → follow the setup steps.
Once Developer Mode is enabled and your server is ready, you’ll be able to:
• Create your bot in the Developer Portal
• Generate your bot token
• Invite your bot to your server
• Test commands and features as you build them
With these steps complete, your Discord environment is fully prepared for bot development.
If you have not yet done so you'll need to Create a new folder on your desktop called discord-bot, open that folder in vs code (or your chosen IDE)
Open the GitHub repository and copy the prepared files into your discord-bot folder: GitHub Repository — how-to-make-a-discord-bot-using-python
just copy bot.py, .env and requirements.txt into you folder calling them the same names.
make sure your IDE recognizes the imports
Open the Discord Developer Portal:
https://discord.com/developers/applications
Click Applications on the left sidebar, Then click new aplication, on the top right youll get apop-up window enter the name of you bot (can be changed later) make sure you click agree to T&C. after you have done this you want to click bot on the left sidebar, scroll down untill you see reset bot token and click reset to generate a new bot token Important: Never share your bot token. Anyone with it can control your bot. coppy paste it into your .env file.
In the Bot settings page, scroll to Privileged Gateway Intents.
Enable:
Presence Intent
Server Members Intent
Message Content Intent
Click Save Changes.
if your in vs code just click the play button in the top left or if your using another IDE run bot.py
if you have done everything right your bot should be online
Go to OAuth2 → URL Generator in the Developer Portal.
Under Scopes, select:
bot
applications.commands
Under Bot Permissions, select:
Read Messages
Send Messages
Use Slash Commands
Copy the generated URL, paste it into your browser, and invite the bot to your server.
In your Discord server, type:
!hello
Your bot should reply:
Hello! I'm alive and running!
If commands are not working, make sure the Message Content Intent is enabled both in your code and in the Developer Portal.
If your bot token is not loading, check your .env file and ensure python-dotenv is installed.
If you get a module error, reinstall the library:
pip install discord.py
Now that your bot is running, you can expand it with new features such as:
• More commands
• Slash commands
• Moderation tools
• Economy systems
• Leveling systems
• Cogs for better organization
This basic bot is just the beginning — you can build almost anything on top of it.
© 2025–2026 Bradley Oliver Beaumont
. All rights reserved.
Made by Bradley Oliver Beaumont.