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
Create the Discord bot, Google OAuth flow, multi-calendar storage, daily Eastern-time scheduler, and per-calendar color rendering.
Add environment templates, dependencies, ignore rules, and step-by-step setup documentation.
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-nowtesting command
Added project files:
bot.pycalendar_cog.pygoogle_calendar.pyoauth_server.pystorage.pyconfig.pyrequirements.txt.env.example.gitignoreREADME.md
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
how do i test this bot in your bot console
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
cd C:\path\to\CalendarSyncBot
macOS/Linux
cd /path/to/CalendarSyncBot
2. Create and activate a virtual environment
Windows
python -m venv .venv
.venv\Scripts\Activate.ps1
macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
3. Install the dependencies
pip install -r requirements.txt
4. Create the .env file
Windows
Copy-Item .env.example .env
macOS/Linux
cp .env.example .env
Open .env and enter:
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:
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
python bot.py
A successful startup should show messages similar to:
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:
Open your application.
Go to OAuth2 > URL Generator.
Select:
botapplications.commands
Give it:
View Channels
Send Messages
Embed Links
Open the generated URL.
Select your test server.
Authorize the bot.
You must have permission to add bots to the server.
7. Test the commands in Discord
In your server, use:
/calendar set-channel
Select the channel where daily calendar posts should appear.
Set Eastern Time:
/calendar set-timezone America/New_York
Connect Google Calendar:
/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:
/calendar list
Test an immediate post:
/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:
/calendar list
You will see a calendar key, such as:
`a1b2c3d4` Work Calendar • #5865F2
Change that calendar’s color:
/calendar set-color a1b2c3d4 #E67E22
Then run:
/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:
/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.commandsscope.Confirm
python bot.pyis 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:
/calendar connect
Complete the Google authorization process, then check:
/calendar list
Google redirects to an error page
Verify that Google Cloud contains this exact redirect URI:
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.
i want to host it on my phone so i don't have to worry about it going offline
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
Create a VPS account from your phone.
Create an Ubuntu server.
Install an SSH app:
Android: Termius or JuiceSSH
iPhone: Termius
Connect to the server using its IP address.
Install Python:
sudo apt update
sudo apt install -y python3 python3-pip python3-venv git
Upload the bot project, either with GitHub:
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
cd YOUR_REPOSITORY
Create the virtual environment and install packages:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Create the environment file:
nano .env
Add your existing Discord and Google credentials:
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
Start the bot:
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:
sudo nano /etc/systemd/system/calendarbot.service
Paste:
[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:
sudo systemctl daemon-reload
sudo systemctl enable calendarbot
sudo systemctl start calendarbot
Check its status:
sudo systemctl status calendarbot
View live logs:
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:
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:
https://your-domain.com/oauth/callback
Then add that exact URL in:
Google Cloud Console
APIs & Services
Credentials
Your OAuth client
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:
Install Termux from F-Droid, not the regular Play Store.
Open Termux and run:
pkg update
pkg install python git tmux
pip install -r requirements.txt
Start it inside a persistent terminal session:
tmux new -s calendarbot
python bot.py
Detach from the session with:
Ctrl+B, then D
Reconnect later with:
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.
what are the scopes listed for the permissions exactly as it is listen on the discord devolper for the bot
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 connectSee 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:
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
what is ython
Python is a programming language—the language this Discord calendar bot is written in.
It lets you create programs using readable commands, such as:
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:
Add Python to PATH
You can verify it is installed by opening a terminal and running:
python --version
or on macOS/Linux:
python3 --version
You should see something similar to:
Python 3.12.4
it's asking to instal cpycthon
It’s probably asking you to install CPython—that is the standard, official version of Python. Yes, install it.
If you’re on Windows
Download Python from python.org/downloads.
Open the installer.
Check:
Add python.exe to PATH
Click Install Now.
After installation, open Command Prompt and run:
python --version
You should see something like:
Python 3.12.4
If you’re using Android Termux
You do not install CPython from a separate website. Run:
pkg update
pkg install python
Then verify it:
python --version
CPython is not a different programming language—it is the normal Python installation needed to run your Discord bot.
now it's saying view online help, what's the next step
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
Close the Python installer.
Open Command Prompt:
Press the Windows key.
Type
cmd.Press Enter.
Check Python:
py --version
You should see something like:
Python 3.12.4
If that works, check pip:
py -m pip --version
Go to the folder containing your bot:
cd C:\path\to\CalendarSyncBot
Replace the path with the actual folder location.
Create a virtual environment:
py -m venv .venv
Activate it:
.venv\Scripts\activate
Install the bot’s dependencies:
py -m pip install -r requirements.txt
Start the bot:
py bot.py
If py --version does not work, try:
python --version
If neither command shows a Python version, send me the exact text displayed on your screen.
wait but i havent made the calendar sync bot path yet
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
Open Command Prompt.
Run:
mkdir "%USERPROFILE%\CalendarSyncBot"
cd /d "%USERPROFILE%\CalendarSyncBot"
Your prompt should now end with something like:
C:\Users\YourName\CalendarSyncBot>
You can also create it manually:
Open File Explorer.
Go to your user folder.
Create a folder named
CalendarSyncBot.
Put the bot files inside it
The folder needs the bot’s files, typically:
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:
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.
how do i get the bot project files
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
Find the project’s Files panel.
Look for an option named Download, Export, or Download ZIP.
Download the ZIP file.
Right-click it and choose Extract All.
Extract it to:
Documents\CalendarSyncBot
The folder should contain files similar to:
CalendarSyncBot
├── bot.py
├── calendar_cog.py
├── requirements.txt
└── .env.example
Then open Command Prompt and run:
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:
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:
copy .env.example .env
Then add your Discord token and Google credentials to .env. Never share that file publicly.
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()