Move all commands to their own files
This commit is contained in:
22
src/commands/clock.rs
Normal file
22
src/commands/clock.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use chrono::Utc;
|
||||
use poise::CreateReply;
|
||||
|
||||
use crate::{models::CtxData, Context, Error};
|
||||
|
||||
/// View the current time in your selected timezone
|
||||
#[poise::command(slash_command)]
|
||||
pub async fn clock(ctx: Context<'_>) -> Result<(), Error> {
|
||||
ctx.defer_ephemeral().await?;
|
||||
|
||||
let tz = ctx.timezone().await;
|
||||
let now = Utc::now().with_timezone(&tz);
|
||||
|
||||
ctx.send(CreateReply::default().ephemeral(true).content(format!(
|
||||
"Time in **{}**: `{}`",
|
||||
tz,
|
||||
now.format("%H:%M")
|
||||
)))
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user