add discord membercount service & endpoint

a background worker is added that sends an approximate member count
request every 60 seconds, caches it into memory, and serves the cache on
a public endpoint
This commit is contained in:
2025-07-09 00:06:56 +02:00
parent fc458143a9
commit 6a12495686
5 changed files with 78 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
use crate::discordbot::MAIN_GUILD_ID;
use serenity::all::{Context, GuildId};
use service::run_membercount_service;
use tracing::info;
mod service;
pub use service::get_member_count;
pub fn init_service(ctx: &Context, guild_id: &GuildId) {
let (ctx, guild_id) = (ctx.clone(), guild_id.clone());
info!("Initialising discord member count service...");
if guild_id != MAIN_GUILD_ID {
info!("Guild member count service not initialised; Bot not running on main guild.");
return;
}
tokio::spawn(async move {
run_membercount_service(ctx, guild_id).await;
});
}