Add option types for top-level commands

This commit is contained in:
jude
2024-02-18 11:04:43 +00:00
parent c1305cfb36
commit 5e39e16060
22 changed files with 395 additions and 268 deletions
+2 -15
View File
@@ -1,22 +1,13 @@
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use crate::{
models::CtxData, time_parser::natural_parser, utils::Extract, ApplicationContext, Context,
Error,
};
use crate::{models::CtxData, time_parser::natural_parser, utils::Extract, Context, Error};
#[derive(Serialize, Deserialize, Extract)]
pub struct Options {
until: Option<String>,
}
impl Extract for Options {
fn extract(ctx: ApplicationContext) -> Self {
Self { until: extract_arg!(ctx, "until", Option<String>) }
}
}
pub async fn pause(ctx: Context<'_>, options: Options) -> Result<(), Error> {
let timezone = ctx.timezone().await;
@@ -73,11 +64,7 @@ pub async fn pause(ctx: Context<'_>, options: Options) -> Result<(), Error> {
}
/// Pause all reminders on the current channel until a certain time or indefinitely
#[poise::command(
slash_command,
identifying_name = "pause",
default_member_permissions = "MANAGE_GUILD"
)]
#[poise::command(slash_command, rename = "pause", default_member_permissions = "MANAGE_GUILD")]
pub async fn command(
ctx: Context<'_>,
#[description = "When to pause until"] until: Option<String>,