Ashley Deters

I need a discord bot that I can connect multiple google calendars to that will make a post about events for that day from the calendars synced into one post at a specific time in eastern time zone. I also need to know exactly how to create said bot with step by step instructions and the ability to change the colors for each calendar individualy

Kodari AI
KodariSep 11 at 6:50 am 2
CalendarSyncBot
A Discord bot that connects multiple Google Calendars and posts a daily consolidated event summary at a specified Eastern Time. Each calendar is assigned a unique color for event differentiation. Includes step-by-step setup instructions, configuration via environment variables, and a command to change individual calendar colors. Built with discord.py, google-api-python-client, and pytz for timezone handling.
  1. Create the Discord bot, Google OAuth flow, multi-calendar storage, daily Eastern-time scheduler, and per-calendar color rendering.

  2. Add environment templates, dependencies, ignore rules, and step-by-step setup documentation.

  1. Built a complete Discord bot with:

    • Multiple Google Calendar account connections

    • Daily combined event posts

    • Eastern Time default timezone with daylight-saving support

    • Configurable daily posting time

    • Per-calendar embed colors

    • Discord slash commands for setup and management

    • OAuth callback server for Google authorization

    • Encrypted Google token storage using Fernet

    • Manual /calendar post-now testing command

  2. Added project files:

    • bot.py

    • calendar_cog.py

    • google_calendar.py

    • oauth_server.py

    • storage.py

    • config.py

    • requirements.txt

    • .env.example

    • .gitignore

    • README.md

  3. Setup instructions are fully documented in README.md, including:

    • Creating the Discord application

    • Configuring Google Calendar API and OAuth

    • Setting the redirect URI

    • Installing dependencies

    • Generating the encryption key

    • Connecting multiple calendars

    • Changing individual calendar colors

    • Configuring timezone, channel, and posting time

Ashley Deters

how do i test this bot in your bot console

Kodari AI
KodariSep 11 at 6:54 am 1

There isn’t a live bot console inside this chat where I can run the Discord bot or log in with your tokens. You test it from a terminal on your computer, then control it through Discord slash commands.

1. Open the bot project in a terminal

Navigate to the folder containing bot.py.

Windows PowerShell

Powershell
cd C:\path\to\CalendarSyncBot

macOS/Linux

Shell
cd /path/to/CalendarSyncBot

2. Create and activate a virtual environment

Windows

Powershell
python -m venv .venv
.venv\Scripts\Activate.ps1

macOS/Linux

Shell
python3 -m venv .venv
source .venv/bin/activate

3. Install the dependencies

Shell
pip install -r requirements.txt

4. Create the .env file

Windows

Powershell
Copy-Item .env.example .env

macOS/Linux

Shell
cp .env.example .env

Open .env and enter:

Dotenv
DISCORD_TOKEN=your_actual_discord_bot_token
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
OAUTH_REDIRECT_URI=http://localhost:8080/oauth/callback
OAUTH_HOST=0.0.0.0
OAUTH_PORT=8080
FERNET_KEY=your_generated_fernet_key
DEFAULT_TIMEZONE=America/New_York
DEFAULT_POST_TIME=09:00

Generate the encryption key with:

Shell
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

Copy the generated value into FERNET_KEY.

Do not paste your Discord token or Google secret into this chat.

5. Start the bot

Shell
python bot.py

A successful startup should show messages similar to:

Plain Text
Logged in as YourBot#0000
Slash commands synced

Keep this terminal open. Closing it stops the bot.

6. Invite the bot to your Discord server

In the Discord Developer Portal:

  1. Open your application.

  2. Go to OAuth2 > URL Generator.

  3. Select:

    • bot

    • applications.commands

  4. Give it:

    • View Channels

    • Send Messages

    • Embed Links

  5. Open the generated URL.

  6. Select your test server.

  7. Authorize the bot.

You must have permission to add bots to the server.

7. Test the commands in Discord

In your server, use:

Plain Text
/calendar set-channel

Select the channel where daily calendar posts should appear.

Set Eastern Time:

Plain Text
/calendar set-timezone America/New_York

Connect Google Calendar:

Plain Text
/calendar connect

The bot will send you a private authorization link. Open it in your browser and approve read-only Google Calendar access.

To connect another Google account, run /calendar connect again.

Check connected calendars:

Plain Text
/calendar list

Test an immediate post:

Plain Text
/calendar post-now

This is the fastest way to verify that the bot can read Google Calendar and send an embed to Discord.

8. Test calendar colors

First run:

Plain Text
/calendar list

You will see a calendar key, such as:

Plain Text
`a1b2c3d4` Work Calendar • #5865F2

Change that calendar’s color:

Plain Text
/calendar set-color a1b2c3d4 #E67E22

Then run:

Plain Text
/calendar post-now

The calendar’s embed should use the new color.

9. Test the automatic daily post

Choose a posting time a few minutes in the future:

Plain Text
/calendar set-time 14:35

The time uses 24-hour format and the configured timezone, which is Eastern Time by default.

The bot checks once per minute. Keep python bot.py running until the scheduled time. It should post the combined calendar message automatically.

Common problems

Slash commands do not appear

  • Confirm the bot was invited with the applications.commands scope.

  • Confirm python bot.py is still running.

  • Restart the bot.

  • Discord may take a short time to display newly synced commands.

/calendar post-now says no calendars are connected

Run:

Plain Text
/calendar connect

Complete the Google authorization process, then check:

Plain Text
/calendar list

Google redirects to an error page

Verify that Google Cloud contains this exact redirect URI:

Plain Text
http://localhost:8080/oauth/callback

It must exactly match OAUTH_REDIRECT_URI in .env.

The bot starts but cannot send messages

Make sure the bot has these permissions in the selected channel:

  • View Channel

  • Send Messages

  • Embed Links

The OAuth page cannot connect

Make sure the bot is running and that port 8080 is available. The browser must be running on the same computer as the bot when using the localhost redirect.

Ashley Deters

i want to host it on my phone so i don't have to worry about it going offline

Kodari AI
KodariSep 11 at 6:56 am 1

You can run it from an Android phone, but a phone cannot guarantee 24/7 uptime. Android may stop background apps, kill the process to save battery, lose network access, or change networks. For truly reliable hosting, use a small cloud server and manage it from your phone.

Best option: host it on a cloud VPS

A VPS stays online even when your phone is off. You can control it from your phone using an SSH app.

Good options include:

  • DigitalOcean

  • Hetzner

  • Oracle Cloud Always Free

  • AWS Lightsail

  • Railway or Render paid services

A basic $5/month VPS is usually enough for this bot.

Phone-based setup

  1. Create a VPS account from your phone.

  2. Create an Ubuntu server.

  3. Install an SSH app:

    • Android: Termius or JuiceSSH

    • iPhone: Termius

  4. Connect to the server using its IP address.

  5. Install Python:

Shell
sudo apt update
sudo apt install -y python3 python3-pip python3-venv git
  1. Upload the bot project, either with GitHub:

Shell
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
cd YOUR_REPOSITORY
  1. Create the virtual environment and install packages:

Shell
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Create the environment file:

Shell
nano .env

Add your existing Discord and Google credentials:

Dotenv
DISCORD_TOKEN=your_discord_token
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
OAUTH_REDIRECT_URI=https://your-domain.com/oauth/callback
OAUTH_HOST=0.0.0.0
OAUTH_PORT=8080
FERNET_KEY=your_fernet_key
DEFAULT_TIMEZONE=America/New_York
DEFAULT_POST_TIME=09:00
  1. Start the bot:

Shell
source .venv/bin/activate
python bot.py

However, do not rely on leaving an SSH window open. Use a service manager so the bot automatically restarts.

Create a service:

Shell
sudo nano /etc/systemd/system/calendarbot.service

Paste:

Ini
[Unit]
Description=Discord Calendar Bot
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/CalendarSyncBot
ExecStart=/home/ubuntu/CalendarSyncBot/.venv/bin/python bot.py
Restart=always
RestartSec=10
User=ubuntu

[Install]
WantedBy=multi-user.target

Change the paths if your project is stored somewhere else.

Enable it:

Shell
sudo systemctl daemon-reload
sudo systemctl enable calendarbot
sudo systemctl start calendarbot

Check its status:

Shell
sudo systemctl status calendarbot

View live logs:

Shell
journalctl -u calendarbot -f

The bot will now keep running even after you disconnect from your phone.

Important Google OAuth change

The current setup uses a localhost callback such as:

Plain Text
http://localhost:8080/oauth/callback

That works when the bot is running on your own computer, but it is not ideal for a remote VPS. You should use a domain or secure tunnel instead:

Plain Text
https://your-domain.com/oauth/callback

Then add that exact URL in:

  1. Google Cloud Console

  2. APIs & Services

  3. Credentials

  4. Your OAuth client

  5. Authorized redirect URIs

You will also need to configure HTTPS, usually with Nginx and Let’s Encrypt.

Running directly on an Android phone

If you specifically want the bot itself on your phone:

  1. Install Termux from F-Droid, not the regular Play Store.

  2. Open Termux and run:

Shell
pkg update
pkg install python git tmux
pip install -r requirements.txt
  1. Start it inside a persistent terminal session:

Shell
tmux new -s calendarbot
python bot.py
  1. Detach from the session with:

Plain Text
Ctrl+B, then D
  1. Reconnect later with:

Shell
tmux attach -t calendarbot

Also disable battery optimization for Termux and keep the phone powered and connected to Wi-Fi. Even then, Android can still stop the process.

Recommendation

Use your phone to access a VPS rather than using the phone as the server. That gives you:

  • 24/7 operation

  • Automatic restarts

  • No dependence on your phone battery

  • Stable Google OAuth access

  • Remote log access from anywhere

Avoid free hosting platforms that put applications to sleep, because the daily scheduler may not run at the configured time.

Ashley Deters

what are the scopes listed for the permissions exactly as it is listen on the discord devolper for the bot

Kodari AI
KodariSep 11 at 7:01 am 1

In the Discord Developer Portal, select these OAuth2 scopes:

OAuth2 → URL Generator → Scopes

  • ✅ bot

  • ✅ applications.commands

Then under Bot Permissions, select:

  • ✅ View Channels

  • ✅ Send Messages

  • ✅ Embed Links

These are the exact permissions needed for the calendar bot to:

  • Appear in your server

  • Use slash commands such as /calendar connect

  • See the configured channel

  • Send the daily calendar post

  • Display calendar events in an embed

You do not need:

  • Administrator

  • Manage Server

  • Read Message History

  • Manage Messages

  • Mention Everyone

  • Attach Files

  • Add Reactions

The final generated invite URL should contain parameters similar to:

Plain Text
scope=bot%20applications.commands
permissions=18432

18432 represents the selected permissions:

  • View Channels

  • Send Messages

  • Embed Links

Also, under Bot → Privileged Gateway Intents, this bot should not require any privileged intents if it only uses slash commands. Leave these disabled:

  • Presence Intent

  • Server Members Intent

  • Message Content Intent

Ashley Deters

what is ython

Kodari AI
KodariSep 11 at 7:18 am 1

Python is a programming language—the language this Discord calendar bot is written in.

It lets you create programs using readable commands, such as:

Python
print("Hello")

For your bot, Python is responsible for:

  • Connecting to Discord

  • Responding to slash commands

  • Connecting to Google Calendar

  • Combining events from multiple calendars

  • Posting the daily schedule

  • Running the bot continuously on a computer, phone, or server

To run the bot, you install Python on the device hosting it. Download it from:

During Windows installation, check:

Plain Text
Add Python to PATH

You can verify it is installed by opening a terminal and running:

Shell
python --version

or on macOS/Linux:

Shell
python3 --version

You should see something similar to:

Plain Text
Python 3.12.4
Ashley Deters

it's asking to instal cpycthon

Kodari AI
KodariSep 11 at 7:20 am 1

It’s probably asking you to install CPython—that is the standard, official version of Python. Yes, install it.

If you’re on Windows

  1. Download Python from python.org/downloads.

  2. Open the installer.

  3. Check:

Plain Text
Add python.exe to PATH
  1. Click Install Now.

  2. After installation, open Command Prompt and run:

Shell
python --version

You should see something like:

Plain Text
Python 3.12.4

If you’re using Android Termux

You do not install CPython from a separate website. Run:

Shell
pkg update
pkg install python

Then verify it:

Shell
python --version

CPython is not a different programming language—it is the normal Python installation needed to run your Discord bot.

Ashley Deters

now it's saying view online help, what's the next step

Kodari AI
KodariSep 11 at 7:21 am 1

If the Python installer is showing “View online help,” the installation is likely complete. You do not need to select it.

Next steps on Windows

  1. Close the Python installer.

  2. Open Command Prompt:

    • Press the Windows key.

    • Type cmd.

    • Press Enter.

  3. Check Python:

Shell
py --version

You should see something like:

Plain Text
Python 3.12.4

If that works, check pip:

Shell
py -m pip --version
  1. Go to the folder containing your bot:

Shell
cd C:\path\to\CalendarSyncBot

Replace the path with the actual folder location.

  1. Create a virtual environment:

Shell
py -m venv .venv
  1. Activate it:

Shell
.venv\Scripts\activate
  1. Install the bot’s dependencies:

Shell
py -m pip install -r requirements.txt
  1. Start the bot:

Shell
py bot.py

If py --version does not work, try:

Shell
python --version

If neither command shows a Python version, send me the exact text displayed on your screen.

Ashley Deters

wait but i havent made the calendar sync bot path yet

Kodari AI
KodariSep 11 at 7:23 am 1

That’s fine—the CalendarSyncBot folder is just the folder where the bot’s files will live. Python can be installed before it exists.

Create the project folder

  1. Open Command Prompt.

  2. Run:

Shell
mkdir "%USERPROFILE%\CalendarSyncBot"
cd /d "%USERPROFILE%\CalendarSyncBot"

Your prompt should now end with something like:

Plain Text
C:\Users\YourName\CalendarSyncBot>

You can also create it manually:

  1. Open File Explorer.

  2. Go to your user folder.

  3. Create a folder named CalendarSyncBot.

Put the bot files inside it

The folder needs the bot’s files, typically:

Plain Text
CalendarSyncBot
├── bot.py
├── requirements.txt
├── .env
└── other project files

If you already downloaded or received the bot files, move them into this folder. If you haven’t created or received the bot code yet, Python alone cannot start the bot—you’ll need the bot project files first.

Once the files are inside the folder, run:

Shell
cd /d "%USERPROFILE%\CalendarSyncBot"
py -m venv .venv
.venv\Scripts\activate
py -m pip install -r requirements.txt
py bot.py

Do not run the last three commands until requirements.txt and bot.py are actually in the folder.

Ashley Deters

how do i get the bot project files

Kodari AI
KodariSep 11 at 7:25 am 1

Installing Python does not include the bot code. You need to download or copy the project files into your computer.

If the project is shown in a file panel

  1. Find the project’s Files panel.

  2. Look for an option named Download, Export, or Download ZIP.

  3. Download the ZIP file.

  4. Right-click it and choose Extract All.

  5. Extract it to:

Plain Text
Documents\CalendarSyncBot

The folder should contain files similar to:

Plain Text
CalendarSyncBot
├── bot.py
├── calendar_cog.py
├── requirements.txt
└── .env.example

Then open Command Prompt and run:

Shell
cd /d "%USERPROFILE%\Documents\CalendarSyncBot"
py -m venv .venv
.venv\Scripts\activate
py -m pip install -r requirements.txt

If there is no Download or Export button

The project files are not currently on your computer. You would need to either:

  • Copy the code for each file into matching files on your computer, or

  • Put the project on GitHub and download it with:

Shell
git clone YOUR_GITHUB_REPOSITORY_URL

Do not create an empty bot.py; it must contain the actual bot code. Also, create .env only after copying .env.example:

Shell
copy .env.example .env

Then add your Discord token and Google credentials to .env. Never share that file publicly.

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
calendar_cog.py
config.py
google_calendar.py
oauth_server.py
README.md
requirements.txt
storage.py
Code
9 942
bot.py
from __future__ import annotations

import logging

import discord
from discord.ext import commands

from calendar_cog import CalendarCog
from config import Settings, load_settings
from oauth_server import OAuthManager
from storage import Storage


logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(name)s: %(message)s",
)
logger = logging.getLogger(__name__)


class CalendarBot(commands.Bot):
    def __init__(self, settings: Settings, storage: Storage, oauth: OAuthManager) -> None:
        intents = discord.Intents.none()
        intents.guilds = True
        super().__init__(command_prefix="!", intents=intents)
        self.settings = settings
        self.storage = storage
        self.oauth = oauth

    async def setup_hook(self) -> None:
        await self.oauth.start()
        await self.add_cog(CalendarCog(self, self.storage, self.oauth))
        await self.tree.sync()
        logger.info("Slash commands synced")

    async def close(self) -> None:
        await self.oauth.stop()
        await super().close()

    async def on_ready(self) -> None:
        logger.info("Logged in as %s", self.user)


def main() -> None:
    settings = load_settings()
    missing = [
        name
        for name, value in {
            "DISCORD_TOKEN": settings.discord_token,
            "GOOGLE_CLIENT_ID": settings.google_client_id,
            "GOOGLE_CLIENT_SECRET": settings.google_client_secret,
        }.items()
        if not value or value.startswith("put_") or value.startswith("your-")
    ]
    if missing:
        raise SystemExit("Missing required environment variables: " + ", ".join(missing))
    storage = Storage(
        settings.data_file,
        settings.default_timezone,
        settings.default_post_time,
        settings.fernet_key,
    )
    oauth = OAuthManager(settings, storage)
    bot = CalendarBot(settings, storage, oauth)
    bot.run(settings.discord_token)


if __name__ == "__main__":
    main()