From 957ebb28044fb6fbf3327892a68739805c08c30f Mon Sep 17 00:00:00 2001 From: minneelyyyy Date: Sat, 7 Dec 2024 23:20:14 -0500 Subject: [PATCH] format duration --- src/commands/gambling/daily.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/commands/gambling/daily.rs b/src/commands/gambling/daily.rs index bb20156..fdd5300 100644 --- a/src/commands/gambling/daily.rs +++ b/src/commands/gambling/daily.rs @@ -3,6 +3,15 @@ use crate::{Context, Error}; use std::time::{Duration, Instant}; use poise::serenity_prelude as serenity; +fn format_duration(duration: Duration) -> String { + let total_seconds = duration.as_secs(); + let seconds = total_seconds % 60; + let minutes = (total_seconds / 60) % 60; + let hours = total_seconds / 3600; + + format!("{:02}:{:02}:{:02}", hours, minutes, seconds) +} + /// Redeem 50 daily tokens. #[poise::command(slash_command, prefix_command)] pub async fn daily(ctx: Context<'_>) -> Result<(), Error> { @@ -23,7 +32,7 @@ pub async fn daily(ctx: Context<'_>) -> Result<(), Error> { ctx.reply("Added **50** credits to your account!").await?; } else { let until_next_daily = Duration::from_secs(10) - daily.elapsed(); - ctx.reply(format!("Your daily will be available in {:?}.", until_next_daily)).await?; + ctx.reply(format!("Your daily will be available in {:?}.", format_duration(until_next_daily))).await?; } }, None => {