The bot for my Discord server.
Join the Discord Server
Note: This repository does not include sensitive tokens and secrets. To use or contribute to this project, you'll need to set up your own credentials.
It's recommended to use a virtual environment to manage dependencies. For detailed instructions, refer to the official Python venv documentation.
-
Create Virtual Environment:
python -m venv venv_name
Replace
venv_name
with a name appropriate for your machine (e.g.,desktop
,laptop
). -
Activate Virtual Environment:
- Windows:
venv_name\Scripts\activate
- macOS/Linux:
source venv_name/bin/activate
- Windows:
-
Activate Virtual Environment:
Ensure your virtual environment is activated (see above).
-
Install Required Packages:
pip install -r requirements.txt
Environment variables need to be set locally using a .env
file. Heroku configurations are handled separately in the Owner Setup section.
Create a .env
file in the root directory of your project and add the following:
CLIENT_ID=your_discord_client_id
CLIENT_SECRET=your_discord_client_secret
TOKEN=your_discord_bot_token
Add your API keys to the .env
file:
REPLICATE_API_TOKEN=your_replicate_api_token
OPENAI_API_KEY=your_openai_api_key
-
Local Setup (
.env
):If your project requires a path to a credentials JSON file, add the following to your
.env
file:GSPREADER_GOOGLE_CREDS_PATH=path/to/your/gspreader_credentials.json
Ensure that the JSON file is not committed to version control.
-
Local Setup (
.env
):Add the path to your Firestore credentials JSON file:
GOOGLE_CREDENTIALS_PATH=path/to/your/google_credentials.json
Execute the following command in the root directory:
python main.py
To debug the bot using VSCode:
- Open
main.py
in VSCode. - Press the Run button or use the shortcut
F5
to start the debugger.
Unit tests are located in the tests/unit_tests
directory.
-
Set Up Environment Variables for Testing:
Ensure that
PYTHONPATH
is set to the root directory. This allowspytest
to locate your modules correctly.- Windows:
set PYTHONPATH=%cd%
- macOS/Linux:
export PYTHONPATH=.
- Windows:
-
Run Unit Tests:
pytest tests/unit_tests
If you do not have
pytest
installed, you can install it using:pip install pytest
For more information, refer to the pytest documentation.
Contributions are welcome! Here's how you can help:
-
Areas of Interest:
bot/on_message
folderbot/scripts
folder
-
Steps to Contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes with clear messages.
- Push to your fork and submit a Pull Request.
Please ensure that you adhere to the project's coding standards and include tests for your contributions.
This section is intended for the project owner only.
Environment variables need to be set on Heroku to ensure the bot functions correctly in the production environment.
-
Navigate to Heroku Dashboard:
- Go to your Heroku Dashboard and select your app.
-
Set Config Vars:
-
Navigate to the Settings tab.
-
Click on "Reveal Config Vars".
-
Add the following variables:
CLIENT_ID=your_discord_client_id CLIENT_SECRET=your_discord_client_secret TOKEN=your_discord_bot_token
REPLICATE_API_TOKEN=your_replicate_api_token OPENAI_API_KEY=your_openai_api_key
-
gspreader [Service Account]:
GSPREADER_GOOGLE_CREDS={"your": "json_content"}
-
Firestore and Google Drive [Service Account]:
GOOGLE_CREDENTIALS={"your": "json_content"}
Ensure that the JSON content is properly formatted as a single-line string.
-
-
This project is configured to automatically deploy to Heroku when you push to the main
branch.
-
Ensure Heroku Remote is Set:
git remote add heroku https://git.heroku.com/your-heroku-app.git
-
Push to Heroku:
git push heroku main
Note: Replace your-heroku-app
with your actual Heroku app name.
-
Create a Discord Application:
- Go to the Discord Developer Portal.
- Click on "New Application" and follow the prompts to create your bot.
-
Authorize the Bot:
- Use the following URL template to authorize your bot:
https://discord.com/oauth2/authorize?client_id=YOUR_BOT_CLIENT_ID&scope=bot&permissions=PERMISSIONS_INT
- Replace
YOUR_BOT_CLIENT_ID
with your bot's client ID. - Set
PERMISSIONS_INT
to the desired permissions integer (e.g.,8
for admin).
- Use the following URL template to authorize your bot:
Ensure that sensitive information such as CLIENT_ID
, CLIENT_SECRET
, and TOKEN
are securely stored and never committed to version control.
Happy Coding! 🚀