Add option types for top-level commands
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
use chrono::Utc;
|
||||
use poise::CreateReply;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{models::CtxData, Context, Error};
|
||||
use crate::{models::CtxData, utils::Extract, Context, Error};
|
||||
|
||||
/// View the current time in your selected timezone
|
||||
#[poise::command(slash_command)]
|
||||
pub async fn clock(ctx: Context<'_>) -> Result<(), Error> {
|
||||
#[derive(Serialize, Deserialize, Extract)]
|
||||
pub struct Options;
|
||||
|
||||
pub async fn clock(ctx: Context<'_>, _options: Options) -> Result<(), Error> {
|
||||
ctx.defer_ephemeral().await?;
|
||||
|
||||
let tz = ctx.timezone().await;
|
||||
@ -20,3 +22,9 @@ pub async fn clock(ctx: Context<'_>) -> Result<(), Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// View the current time in your selected timezone
|
||||
#[poise::command(slash_command, rename = "clock")]
|
||||
pub async fn command(ctx: Context<'_>) -> Result<(), Error> {
|
||||
clock(ctx, Options {}).await
|
||||
}
|
||||
|
Reference in New Issue
Block a user