From 678fa660398fb507535f602ec53b48f76fdf3190 Mon Sep 17 00:00:00 2001 From: jakubmanczak Date: Sun, 1 Jun 2025 12:53:40 +0200 Subject: [PATCH] wait 10s before calculating next midnight for daily service Discord logs the icon/name changes twice, with a different name each time. The guild update service is likely running twice, possibly due to faulty calculations of the next midnight - after the first run, it might calculate a very short sleep period or none at all, only sleeping until next midnight afterwards. The cause of this is unknown, but if it has to do with system time, waiting for the 10 seconds might be enough to let the system recognise the date change and allow it to sleep for the proper ~24h. --- src/discordbot/events/service.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/discordbot/events/service.rs b/src/discordbot/events/service.rs index 873ceee..2dcd0f7 100644 --- a/src/discordbot/events/service.rs +++ b/src/discordbot/events/service.rs @@ -8,6 +8,9 @@ use super::Event; pub async fn run_event_service(ctx: Context, guild_id: GuildId) { loop { update_guild(&ctx, guild_id).await.ok(); + + // make sure temporal boundaries have been cleared + tokio::time::sleep(std::time::Duration::from_secs(10)).await; sleep_until_next_midnight().await; } }