Skip to main content

Prerequisites

Before you begin, make sure you have:
  • A Discord account with permission to create bot applications
  • A Google Sheets document with your schedule data
  • Docker installed on your system (or Python 3.11+ for local development)
  • Basic familiarity with terminal/command line

Step 1: Create a Discord bot

1

Go to Discord Developer Portal

Navigate to discord.com/developers/applications and log in with your Discord account.
2

Create a new application

Click New Application, give it a name (e.g., “Planning Bot”), and accept the terms.
3

Configure the bot

In the left sidebar, go to Bot section and click Add Bot. Confirm by clicking Yes, do it!
4

Get your bot token

Under the bot’s username, click Reset Token and copy the token.
Keep this token secret! Anyone with this token can control your bot. Never commit it to version control.
5

Enable necessary intents

Scroll down to Privileged Gateway Intents and enable:
  • Message Content Intent (if needed for future features)
The current bot uses default intents, so this step is optional but recommended for future extensibility.
6

Invite bot to your server

Go to OAuth2URL Generator:
  • Select scope: bot and applications.commands
  • Select permissions: Send Messages, Attach Files
  • Copy the generated URL and open it in your browser to invite the bot

Step 2: Prepare your Google Sheets

1

Format your schedule spreadsheet

Your Google Sheets should have a structure with:
  • Row 4 onwards containing schedule data (first 3 rows are skipped)
  • Monthly sections with headers like “JANVIER”, “FÉVRIER”, etc.
  • Three columns per month: Day, Morning, Afternoon
  • Course codes in cells (e.g., “UTC501”, “NFP121”)
2

Share your spreadsheet

Click Share in the top-right corner and set sharing to Anyone with the link can view.
3

Get the CSV export URL

Copy your spreadsheet URL and append /export?format=csv to the end.Example:
https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/export?format=csv
The bot expects specific month names in French (JANVIER, FÉVRIER, etc.) in the first row of data. Make sure your spreadsheet follows this format.

Step 3: Configure environment variables

Create a .env file in your project directory with your credentials:
.env
DISCORD_TOKEN=your_discord_bot_token_here
EDT_PATH=https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/export?format=csv
Never commit your .env file to version control. Add it to .gitignore to prevent accidental exposure of credentials.

Step 4: Deploy with Docker

1

Download the source code

Clone or download the bot source code to your local machine:
git clone <repository-url>
cd bot-planning
2

Build the Docker image

Build the Docker container using the provided Dockerfile:
docker build -t bot-planning .
This creates a lightweight Python 3.11 container with all dependencies installed.
3

Run the container

Start the bot with your environment variables:
docker run -d --name bot-planning \
  --env-file .env \
  --restart always \
  bot-planning:latest
The --restart always flag ensures the bot automatically restarts if it crashes or when Docker starts.
4

Verify the bot is running

Check the container logs to confirm successful startup:
docker logs bot-planning
You should see:
✅ Bot connecté en tant que YourBotName#1234
✅ Slash commands synchronisées

Step 5: Test the bot

1

Check bot status

In your Discord server, verify the bot appears online in the member list.
2

Use the /planning command

Type /planning in any channel where the bot has permissions. The bot will generate and send an image of the current week’s schedule.
Slash commands may take up to an hour to appear in Discord after first deployment due to Discord’s caching.
3

Try with a specific date

Test the date parameter by using:
/planning date:15-03-2026
The bot will display the schedule for the week containing March 15, 2026.

Alternative: Run locally without Docker

If you prefer to run the bot without Docker:
1

Install Python dependencies

Make sure you have Python 3.11+ installed, then:
pip install -r requirements.txt
Required packages:
requirements.txt
discord.py
pandas
matplotlib
python-dotenv
2

Run the bot

Start the bot directly with Python:
python bot.py

Troubleshooting

  • Wait up to 1 hour for Discord to sync slash commands
  • Check bot permissions in the channel (Send Messages, Attach Files)
  • Verify the bot is online in the member list
  • Check Docker logs for errors: docker logs bot-planning
  • Verify your Google Sheets has month headers in French (JANVIER, FÉVRIER, etc.)
  • Check that the CSV export URL is correct and accessible
  • Ensure your spreadsheet structure matches the expected format (data starts at row 4)
  • Verify your DISCORD_TOKEN is correct and hasn’t been reset
  • Check that EDT_PATH URL is accessible and returns CSV data
  • Ensure .env file is in the correct location
  • Check Docker logs: docker logs bot-planning
  • The week may genuinely have no classes scheduled
  • Verify data exists in your Google Sheets for that week
  • Check that course codes are recognized (see configuration docs)

Next steps

Your bot is now running! Here’s what you can explore next:

Customize course codes

Learn how to map course codes to full subject names

Advanced features

Explore color customization and date handling

Build docs developers (and LLMs) love