Link all top-level commands with macro recording/replaying logic
This commit is contained in:
@ -2,29 +2,35 @@ use chrono::Utc;
|
||||
use poise::CreateReply;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{models::CtxData, utils::Extract, Context, Error};
|
||||
use crate::{
|
||||
models::CtxData,
|
||||
utils::{Extract, Recordable},
|
||||
Context, Error,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Extract)]
|
||||
pub struct Options;
|
||||
|
||||
pub async fn clock(ctx: Context<'_>, _options: Options) -> Result<(), Error> {
|
||||
ctx.defer_ephemeral().await?;
|
||||
impl Recordable for Options {
|
||||
async fn run(self, ctx: Context<'_>) -> Result<(), Error> {
|
||||
ctx.defer_ephemeral().await?;
|
||||
|
||||
let tz = ctx.timezone().await;
|
||||
let now = Utc::now().with_timezone(&tz);
|
||||
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?;
|
||||
ctx.send(CreateReply::default().ephemeral(true).content(format!(
|
||||
"Time in **{}**: `{}`",
|
||||
tz,
|
||||
now.format("%H:%M")
|
||||
)))
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// View the current time in your selected timezone
|
||||
#[poise::command(slash_command, rename = "clock")]
|
||||
#[poise::command(slash_command, rename = "clock", identifying_name = "clock")]
|
||||
pub async fn command(ctx: Context<'_>) -> Result<(), Error> {
|
||||
clock(ctx, Options {}).await
|
||||
(Options {}).run(ctx).await
|
||||
}
|
||||
|
Reference in New Issue
Block a user