From 6be649f0fc00a0d7e166252f5dbe5a6629f82be4 Mon Sep 17 00:00:00 2001 From: Jet Pham <55770902+jetpham@users.noreply.github.com> Date: Fri, 6 Jun 2025 20:32:55 -0700 Subject: [PATCH] feat: remove shutdown message because it doesn't hit --- src/discord.rs | 20 -------------------- src/main.rs | 21 --------------------- 2 files changed, 41 deletions(-) diff --git a/src/discord.rs b/src/discord.rs index ec6e755..088fe37 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -83,24 +83,4 @@ impl DiscordClient { info!("Discord startup message sent successfully in {:?}", duration); Ok(()) } - - pub async fn send_shutdown_message(&self) -> Result<()> { - let start = Instant::now(); - info!("Sending Discord shutdown message"); - - let embed = CreateEmbed::new() - .title("Noisebell is shutting down") - .description("The Noisebell service is stopping. Status updates won't go through") - .color(Color::new(0x800080)) // Purple for shutdown - .thumbnail("https://static.vecteezy.com/system/resources/thumbnails/050/619/685/large/a-laptop-computer-on-fire-on-a-desk-in-a-dark-room-video.jpg"); - - if let Err(why) = self.channel_id.send_message(&self.client.http, CreateMessage::default().add_embed(embed)).await { - error!("Error sending Discord shutdown message: {:?}", why); - return Err(anyhow::anyhow!("Failed to send Discord shutdown message: {}", why)); - } - - let duration = start.elapsed(); - info!("Discord shutdown message sent successfully in {:?}", duration); - Ok(()) - } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5beb7e0..0e855ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,22 +11,6 @@ use tracing_appender::rolling::{RollingFileAppender, Rotation}; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; -struct ShutdownGuard { - discord_client: Arc, -} - -impl Drop for ShutdownGuard { - fn drop(&mut self) { - info!("Shutdown guard triggered"); - let runtime = tokio::runtime::Runtime::new().unwrap(); - runtime.block_on(async { - if let Err(e) = self.discord_client.send_shutdown_message().await { - error!("Failed to send shutdown message: {}", e); - } - }); - } -} - #[tokio::main] async fn main() -> Result<()> { info!("creating logs directory"); @@ -58,11 +42,6 @@ async fn main() -> Result<()> { let discord_client = discord::DiscordClient::new().await?; let discord_client = Arc::new(discord_client); - // Create shutdown guard that will send message on any exit - let _guard = ShutdownGuard { - discord_client: Arc::clone(&discord_client), - }; - discord_client.send_startup_message().await?; const DEFAULT_GPIO_PIN: u8 = 17;