feat: delete message after 5 s

This commit is contained in:
Max batleforc 2025-06-10 21:34:50 +02:00
parent 3c8a456b2c
commit 00ef0c09c5
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7

View File

@ -142,7 +142,18 @@ pub async fn event_handler(
.content("Answer taken into account!")
.reference_message(new_message)
.flags(serenity::MessageFlags::EPHEMERAL);
channel_id.send_message(&ctx.http, builder).await?;
match channel_id.send_message(&ctx.http, builder).await {
Ok(msg) => {
// sleep for a short duration to ensure the message is sent
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
msg.delete(ctx).await.unwrap_or_else(|e| {
tracing::error!("Failed to delete ephemeral message: {}", e);
});
}
Err(e) => {
tracing::error!("Failed to send message: {}", e);
}
}
Ok(())
}
.instrument(span!(