Skip to main content
The Bot Planning application requires two essential environment variables to function properly. These variables are loaded from a .env file in your project root using the python-dotenv library.

Required Variables

DISCORD_TOKEN
string
required
Your Discord bot authentication token. This token allows your application to connect to Discord’s API and interact with servers.Location in code: bot.py:18
TOKEN = str(os.getenv("DISCORD_TOKEN"))
Never commit your Discord token to version control. Keep it secure in your .env file and add .env to your .gitignore.
EDT_PATH
string
required
The URL or file path to your CSV file exported from Google Sheets. This CSV contains your schedule data in the required format.Location in code: bot.py:19
SHEET_PATH = str(os.getenv("EDT_PATH"))
Example values:
  • Google Sheets CSV export URL: https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/export?format=csv
  • Local file path: /path/to/your/schedule.csv

Setup Instructions

1

Create .env file

Create a .env file in your project root directory (same location as bot.py):
touch .env
2

Add environment variables

Open the .env file and add your configuration:
DISCORD_TOKEN=your_discord_bot_token_here
EDT_PATH=https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/export?format=csv
Replace:
  • your_discord_bot_token_here with your actual Discord bot token
  • YOUR_SHEET_ID with your Google Sheets document ID
3

Verify .gitignore

Ensure your .env file is excluded from version control:
echo ".env" >> .gitignore
4

Install python-dotenv

The bot uses python-dotenv to load environment variables:
pip install python-dotenv

How It Works

The bot loads environment variables at startup using:
from dotenv import load_dotenv
import os

load_dotenv()

TOKEN = str(os.getenv("DISCORD_TOKEN"))
SHEET_PATH = str(os.getenv("EDT_PATH"))
This approach keeps sensitive credentials out of your source code while making them easily configurable across different environments.
If either DISCORD_TOKEN or EDT_PATH is missing or invalid, the bot will fail to start or be unable to fetch schedule data.

Troubleshooting

Bot won’t start:
  • Verify your .env file is in the same directory as bot.py
  • Check that DISCORD_TOKEN is set correctly
  • Ensure there are no extra spaces or quotes around the values
Can’t load schedule data:
  • Verify EDT_PATH URL is accessible
  • Check that the Google Sheets CSV export link is publicly accessible or properly authenticated
  • Test the URL in your browser to ensure it downloads a CSV file

Build docs developers (and LLMs) love