Move all commands to their own files
This commit is contained in:
48
src/commands/remind.rs
Normal file
48
src/commands/remind.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use chrono_tz::Tz;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::autocomplete::{time_hint_autocomplete, timezone_autocomplete},
|
||||
models::reminder::create_reminder,
|
||||
ApplicationContext, Context, Error,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub struct RemindOptions {
|
||||
pub time: String,
|
||||
pub content: String,
|
||||
pub channels: Option<String>,
|
||||
pub interval: Option<String>,
|
||||
pub expires: Option<String>,
|
||||
pub tts: Option<bool>,
|
||||
pub timezone: Option<Tz>,
|
||||
}
|
||||
|
||||
/// Create a reminder. Press "+4 more" for other options. Use "/multiline" for multiline content.
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
identifying_name = "remind",
|
||||
default_member_permissions = "MANAGE_GUILD"
|
||||
)]
|
||||
pub async fn remind(
|
||||
ctx: ApplicationContext<'_>,
|
||||
#[description = "The time (and optionally date) to set the reminder for"]
|
||||
#[autocomplete = "time_hint_autocomplete"]
|
||||
time: String,
|
||||
#[description = "The message content to send"] content: String,
|
||||
#[description = "Channel or user mentions to set the reminder for"] channels: Option<String>,
|
||||
#[description = "(Patreon only) Time to wait before repeating the reminder. Leave blank for one-shot reminder"]
|
||||
interval: Option<String>,
|
||||
#[description = "(Patreon only) For repeating reminders, the time at which the reminder will stop repeating"]
|
||||
expires: Option<String>,
|
||||
#[description = "Set the TTS flag on the reminder message, similar to the /tts command"]
|
||||
tts: Option<bool>,
|
||||
#[description = "Set a timezone override for this reminder only"]
|
||||
#[autocomplete = "timezone_autocomplete"]
|
||||
timezone: Option<String>,
|
||||
) -> Result<(), Error> {
|
||||
let tz = timezone.map(|t| t.parse::<Tz>().ok()).flatten();
|
||||
|
||||
create_reminder(Context::Application(ctx), time, content, channels, interval, expires, tts, tz)
|
||||
.await
|
||||
}
|
Reference in New Issue
Block a user