This is a simple example of a Discord bot implemented in Python using dotenv-python
for managing sensitive keys, py-cord
for interacting with the Discord API, and cogwatch
for dynamic cog reloading.
This repo can be forked and modified to include unlimited capabilities and features; from complex view-flows, modals, MySQL, anything!
- Loads Discord token and other sensitive keys from a
.env
file. - Loads less sensitive configuration from
bot_config.json
- Implements a single slash command example,
/ping
- Utilizes
cogwatch
for hot-reloading modules in thecogs
sub-directory.
- Python 3.8+
dotenv-python
py-cord
(https://docs.pycord.dev/en/stable/api/index.html)cogwatch
(https://github.com/robertwayne/cogwatch)
-
Clone the repository:
git clone https://github.com/cozmycc/PythonDiscordBot.git cd PythonDiscordBot
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up your
.env
file:Create a file named
.env
in the root directory of your project, if it doesn't already exist, and add the following:DISCORD_TOKEN=your_discord_token_here
-
Run the bot:
python bot.py
-
Interact with the bot:
Use the slash command
/ping
in your Discord server where the bot is present to verify it is working.
{
"main": {
"version": "1.0.0"
}
}