Have you ever been on Discord? If yes, then you've probably seen a Discord bot before, they appear as regular members in a server, except with a "BOT" tag next to their username. In Discord, a bot can be summoned by sending a command in chat.
Prerequisites
This tutorial expects you to have at least a decent understanding of Python. Rest assured, even if we will use async
syntax, an understanding of asynchronous programming is not needed.
Preparing our dev environment.
First things first, we'll need to install a version of Python higher than 3.8. If you don't already have it installed, you can install it here.
Once you've installed Python, you can check if your python executable is working properly by making it print the Python version. On linux/macOS:
$ python3 --version
Windows:
C:\> python --version
If your Python executable is working properly, you should see this:
Python 3.8.10 # This number can be higher, but not lower.
This step is optional, but highly recommended. We will create a
virtual environment using venv
. In your Discord bot's root directory, execute this command:
python3 -m venv .venv # Linux/macOS
Windows:
C:\> python -m venv.venv
We can activate our environment using source
on Linux/macOS
$ source /.venv/bin/activate
On Windows:
C:\> /.venv/Scripts/activate.bat
Almost there! All we have to do now is to install Discord.py v2.0
using pip
. Linux/macOS:
$ python3 -m pip3 install -U git+https://github.com/Rapptz/discord.py
Windows:
C:\> python -m pip install -U git+https://github.com/Rapptz/discord.py
Once that's done, you did it! We have successfully prepared our environment to start writing our Discord bot, see you in the next tutorial!
Top comments (0)