From 2a8117d0c1870524dc05e8efbb157b3db72d81d4 Mon Sep 17 00:00:00 2001 From: jude Date: Tue, 20 Sep 2022 17:00:33 +0100 Subject: [PATCH] Revert multiline changes --- src/commands/autocomplete.rs | 14 ------- src/commands/reminder_cmds.rs | 75 ++++++++++++++++++++--------------- src/main.rs | 1 + 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/commands/autocomplete.rs b/src/commands/autocomplete.rs index 53725b4..255f345 100644 --- a/src/commands/autocomplete.rs +++ b/src/commands/autocomplete.rs @@ -37,20 +37,6 @@ WHERE .collect() } -pub async fn multiline_autocomplete( - _ctx: Context<'_>, - partial: &str, -) -> Vec> { - if partial.is_empty() { - vec![AutocompleteChoice { name: "Multiline content...".to_string(), value: "".to_string() }] - } else { - vec![ - AutocompleteChoice { name: partial.to_string(), value: partial.to_string() }, - AutocompleteChoice { name: "Multiline content...".to_string(), value: "".to_string() }, - ] - } -} - pub async fn time_hint_autocomplete( ctx: Context<'_>, partial: &str, diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index 3e320d0..1d41bf2 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -15,9 +15,7 @@ use poise::{ }; use crate::{ - commands::autocomplete::{ - multiline_autocomplete, time_hint_autocomplete, timezone_autocomplete, - }, + commands::autocomplete::{time_hint_autocomplete, timezone_autocomplete}, component_models::{ pager::{DelPager, LookPager, Pager}, ComponentDataModel, DelSelector, UndoReminder, @@ -562,7 +560,45 @@ struct ContentModal { content: String, } -/// Create a reminder. Press "+4 more" for other options. +/// Create a reminder with multi-line content. Press "+4 more" for other options. +#[poise::command( + slash_command, + identifying_name = "multiline", + default_member_permissions = "MANAGE_GUILD" +)] +pub async fn multiline( + ctx: ApplicationContext<'_>, + #[description = "A description of the time to set the reminder for"] + #[autocomplete = "time_hint_autocomplete"] + time: String, + #[description = "Channel or user mentions to set the reminder for"] channels: Option, + #[description = "(Patreon only) Time to wait before repeating the reminder. Leave blank for one-shot reminder"] + interval: Option, + #[description = "(Patreon only) For repeating reminders, the time at which the reminder will stop repeating"] + expires: Option, + #[description = "Set the TTS flag on the reminder message, similar to the /tts command"] + tts: Option, + #[description = "Set a timezone override for this reminder only"] + #[autocomplete = "timezone_autocomplete"] + timezone: Option, +) -> Result<(), Error> { + let tz = timezone.map(|t| t.parse::().ok()).flatten(); + let data = ContentModal::execute(ctx).await?; + + create_reminder( + Context::Application(ctx), + time, + data.content, + channels, + interval, + expires, + tts, + tz, + ) + .await +} + +/// Create a reminder. Press "+4 more" for other options. Use "/multiline" for multiline content. #[poise::command( slash_command, identifying_name = "remind", @@ -573,9 +609,7 @@ pub async fn remind( #[description = "A description of the time to set the reminder for"] #[autocomplete = "time_hint_autocomplete"] time: String, - #[description = "The message content to send"] - #[autocomplete = "multiline_autocomplete"] - content: String, + #[description = "The message content to send"] content: String, #[description = "Channel or user mentions to set the reminder for"] channels: Option, #[description = "(Patreon only) Time to wait before repeating the reminder. Leave blank for one-shot reminder"] interval: Option, @@ -589,33 +623,8 @@ pub async fn remind( ) -> Result<(), Error> { let tz = timezone.map(|t| t.parse::().ok()).flatten(); - if content.is_empty() { - let data = ContentModal::execute(ctx).await?; - - create_reminder( - Context::Application(ctx), - time, - data.content, - channels, - interval, - expires, - tts, - tz, - ) + create_reminder(Context::Application(ctx), time, content, channels, interval, expires, tts, tz) .await - } else { - create_reminder( - Context::Application(ctx), - time, - content, - channels, - interval, - expires, - tts, - tz, - ) - .await - } } async fn create_reminder( diff --git a/src/main.rs b/src/main.rs index aa0d0cd..011692e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,6 +133,7 @@ async fn _main(tx: Sender<()>) -> Result<(), Box> { ], ..reminder_cmds::timer_base() }, + reminder_cmds::multiline(), reminder_cmds::remind(), poise::Command { subcommands: vec![