Discord bot for SACNAS UH to automate event announcements and reminders.
The source of truth for events is a Google Sheet, containing event information including titles, descriptions, dates, images, and associated event links. See the SACNAS-UH-Website README for details on Google Sheets usage, and Google Apps Script automation.
This bot fetches event information from Google Sheets at a set interval (currently daily at a specific time). It then filters through events and announces events 1 week ahead of time, and again on the day of the event.
All event announcements are logged, to avoid repeated announcements, and (in addition to the fetch on the set interval) event info is fetched upon bot startup, in case the bot happens to be down during the scheduled fetch interval.
Event announcements feature all event information, including titles, descriptions, dates, locations, images, and associated event links.
Admins can preview upcoming event announcements using multiple methods.
Firstly, an automated reminder is sent to an admin channel 2 days prior to event announcements, with a preview of the announcement. This reminds admins to double-check event info and formatting before the announcement is sent out.
Upon making changes to event information, admins can manually preview an event announcement using the !preview
command. By default, announcement previews will be generated for all upcoming events, but a specific event can be specified by adding a number that corresponds to the event's order in the upcoming events list. For example, !preview 1
will generate an announcement preview only for the soonest upcoming event; !preview 2
will generate a preview for the second upcoming event, etc.
Admins can manually announce events using the !announce
command. Similarly to previews, this command takes the index of the event to be announced, ex. !announce 1
to announce the soonest upcoming event. The announcement will not occur unless a specific event index is given.
This allows admins to manually announce events, in case they weren't added to the Google Sheet more than 1 week in advance (thus the bot's 1 week announcement wouldn't go off), or in case the event needs to be announced more than 1 week ahead (ex. event requiring travel or application).
In addition to announcement messages, this bot also generates scheduled events within the discord server. This allows users to RSVP prior to the event, and persists in the server as a reminder of the upcoming event. These events are added to the server as soon as they are added to the Google Sheet (upon the next fetch interval), rather than being added in tandem with event announcement messages. This gives users a longer-term warning ahead of time, and provides a running list of upcoming events within the Discord server, that is consistent with the website and Google Sheet.
Admins can view the following statistics using the !stats
command:
- Time active
- Server members
- Events announced
- Discord events created
The bot's Discord status also displays the total number of announcements made and users in its server(s). These statistics are updated upon startup, and upon each event announcement message.
- Push event updates from Google Sheets to scheduled events in the Discord server
- Currently, if an event is scheduled in the Discord server, and changes are made to the event in the Google Sheet, those changes are not reflected on Discord. This creates more work for admins, who have to manually update the Discord event.
- Add manual announcement option
- Auto-generated directions to event (pass event location into a Google Maps URL)
- Auto-generated "Add to Calendar" link (pass event info into a Google Calendar URL)
- Event images are not added to Discord Scheduled Events
- Images are included in the POST request to create the Discord event, but the response returns
image: null
. - This is on the backburner as it's not a severe breaking issue, but something I'd like to fix in the future.
- Images are included in the POST request to create the Discord event, but the response returns
If you'd like to fork the bot for your own usage, use the following instructions to set up your environment:
- Env variables
DISCORD_BOT_TOKEN
- Your Discord bot tokenANNOUNCEMENT_CHANNEL_ID
- The Discord channel ID for official announcementsADMIN_CHANNEL_ID
- The Discord channel for admin warnings and previewsGOOGLE_API_KEY
- Your Google API Key (needs Google Sheets API access)EVENTS_SHEET_ID
- The Google Sheets ID for the source of truth for eventsDISCORD_GUILD_ID
- Your Discord Guild ID
- Google Sheets configuration
Title Summary Location Date Time Image URL Link 1 Label Link 1 URL Link 2 Label Link 2 URL My Event Come hang out! Houston, TX Wednesday, January 24, 2024 4:00 PM https://i.imgur.com/eMMDrp2.jpeg RSVP https://a.com Volunteer https://b.com - Note the format of dates:
EEEE, MMMM dd, yyyy
(i.e. "Thursday, February 1, 2024")- This is formatted on the Google Sheet, and code in this repo is made to handle that format. You may need to adjust the code, or format your Google Sheets dates accordingly.
- Note that in my Google Sheets configuration, a sheet called "Upcoming" is used to store upcoming event data.
- Previous events are automatically archived using Google Apps Script. See the SACNAS-UH-Website README for details