From 963ff83c9f9fdca605be6dfb47591c1199220871 Mon Sep 17 00:00:00 2001 From: Tahmid Ahmed Date: Wed, 7 Oct 2026 00:21:01 -0400 Subject: [PATCH] TAN-1045: Update standup bot to make ROLE_ID configurable by env --- internal/standup-bot/README.md | 4 ++++ internal/standup-bot/example.env | 2 ++ internal/standup-bot/example.env.production | 2 ++ internal/standup-bot/src/discord/mod.rs | 7 ++++--- internal/standup-bot/src/env.rs | 5 +++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/internal/standup-bot/README.md b/internal/standup-bot/README.md index e69bc60bd..8636ca1ef 100644 --- a/internal/standup-bot/README.md +++ b/internal/standup-bot/README.md @@ -14,6 +14,10 @@ Codebloom Standup Bot is an internal application written in [Rust](https://rust- 1. Fill out your `.env` file 1. Simply run `cargo run` to compile & run the binary. +`DISCORD_ROLE_ID` is required and must be an unsigned 64-bit integer. It selects +the role mentioned in standup messages and the members eligible for end-of-day +reminders. Set it in `.env` locally and in the deployed service's environment. + ### Deployment _Last updated: 02/15/2026_ diff --git a/internal/standup-bot/example.env b/internal/standup-bot/example.env index acd641b66..24b73a5c4 100644 --- a/internal/standup-bot/example.env +++ b/internal/standup-bot/example.env @@ -5,6 +5,8 @@ DISCORD_TOKEN= # Point to guild and channel to send standup messages. DISCORD_GUILD_ID= DISCORD_CHANNEL_ID= +# Role to mention and select for end-of-day reminders. +DISCORD_ROLE_ID= REDIS_URI= diff --git a/internal/standup-bot/example.env.production b/internal/standup-bot/example.env.production index 000a8784b..f5b3e5e53 100644 --- a/internal/standup-bot/example.env.production +++ b/internal/standup-bot/example.env.production @@ -5,6 +5,8 @@ DISCORD_TOKEN= # Point to guild and channel to send standup messages. DISCORD_GUILD_ID= DISCORD_CHANNEL_ID= +# Role to mention and select for end-of-day reminders. +DISCORD_ROLE_ID= REDIS_URI= diff --git a/internal/standup-bot/src/discord/mod.rs b/internal/standup-bot/src/discord/mod.rs index 373e12704..05a131776 100644 --- a/internal/standup-bot/src/discord/mod.rs +++ b/internal/standup-bot/src/discord/mod.rs @@ -40,13 +40,13 @@ use crate::{ }; const INTENTS: GatewayIntents = GatewayIntents::GUILD_MEMBERS.union(GatewayIntents::GUILD_MESSAGES); -const ROLE_ID: u64 = 1534007500121313341; pub struct DiscordClient { http: Arc, cache: Arc, guild_id: u64, channel_id: u64, + role_id: u64, } impl DiscordClient { @@ -79,6 +79,7 @@ impl DiscordClient { cache, guild_id: creds.guild_id, channel_id: creds.channel_id, + role_id: creds.role_id, }) } @@ -96,7 +97,7 @@ impl DiscordClient { ) .colour(Colour::from_rgb(69, 129, 103)); let create_msg = CreateMessage::new() - .content(format!("<@&{ROLE_ID}>")) + .content(format!("<@&{}>", self.role_id)) .embed(embed); let channel = ChannelId::new(self.channel_id); @@ -117,7 +118,7 @@ impl DiscordClient { pub async fn get_standup_role_members(&self) -> Result, DiscordClientError> { let guild = GuildId::new(self.guild_id); - let role = RoleId::new(ROLE_ID); + let role = RoleId::new(self.role_id); let members = self .cache diff --git a/internal/standup-bot/src/env.rs b/internal/standup-bot/src/env.rs index e33552dd4..8596aa1aa 100644 --- a/internal/standup-bot/src/env.rs +++ b/internal/standup-bot/src/env.rs @@ -14,6 +14,7 @@ pub struct DiscordCredentials { pub token: String, pub guild_id: u64, pub channel_id: u64, + pub role_id: u64, } impl DiscordCredentials { @@ -35,6 +36,10 @@ impl DiscordCredentials { .context("DISCORD_CHANNEL_ID is missing from environment")? .parse() .context("DISCORD_CHANNEL_ID is not an integer type")?, + role_id: env::var("DISCORD_ROLE_ID") + .context("DISCORD_ROLE_ID is missing from environment")? + .parse() + .context("DISCORD_ROLE_ID is not an integer type")?, }) } }