About discord.py
Discord.py is a Python library for building Discord bots. It provides an easy-to-use interface for interacting with the Discord API, allowing developers to create bots that can perform a wide range of tasks, such as moderating channels, automating tasks, and responding to user commands.
Using discord.py, developers can create custom commands, event listeners, and message handlers to interact with the Discord API. They can also integrate external APIs, such as weather APIs or news APIs, to provide additional functionality to their bots.
-
Install Python 3.8 or later
-
Create a virtual environment:
python3 -m venv venv -
Activate the virtual environment:
Linux
source venv/bin/activateWindows
venv/scripts/activate -
Install dependencies:
pip install -r requirements.txt -
Create a
.envfile following the format of.env.exampleand fill in the required values -
Run the app:
python3 src/client.py
-
Go to the Discord Developer Portal and select your bot application.
-
Navigate to the OAuth2 tab on the left-hand side of the screen.
-
Under the OAuth2 URL Generator section, select the bot checkbox under the Scopes section.
-
Scroll down to the Bot Permissions section and select the permissions you want your bot to have.
-
Copy the generated OAuth2 URL under the Scopes section.
-
Paste the generated URL into your browser and authorize the bot to join your server.