Use autocomplete to ensure content box is shown
This commit is contained in:
parent
f20b95a482
commit
8991198fd3
@ -11,7 +11,7 @@ use poise::{
|
|||||||
serenity_prelude::{
|
serenity_prelude::{
|
||||||
builder::CreateEmbed, component::ButtonStyle, model::channel::Channel, ReactionType,
|
builder::CreateEmbed, component::ButtonStyle, model::channel::Channel, ReactionType,
|
||||||
},
|
},
|
||||||
CreateReply, Modal,
|
AutocompleteChoice, CreateReply, Modal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -549,6 +549,20 @@ pub async fn delete_timer(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn multiline_autocomplete(
|
||||||
|
_ctx: Context<'_>,
|
||||||
|
partial: &str,
|
||||||
|
) -> Vec<AutocompleteChoice<String>> {
|
||||||
|
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() },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(poise::Modal)]
|
#[derive(poise::Modal)]
|
||||||
#[name = "Reminder"]
|
#[name = "Reminder"]
|
||||||
struct ContentModal {
|
struct ContentModal {
|
||||||
@ -568,7 +582,9 @@ struct ContentModal {
|
|||||||
pub async fn remind(
|
pub async fn remind(
|
||||||
ctx: ApplicationContext<'_>,
|
ctx: ApplicationContext<'_>,
|
||||||
#[description = "A description of the time to set the reminder for"] time: String,
|
#[description = "A description of the time to set the reminder for"] time: String,
|
||||||
#[description = "The message content to send"] content: Option<String>,
|
#[description = "The message content to send"]
|
||||||
|
#[autocomplete = "multiline_autocomplete"]
|
||||||
|
content: String,
|
||||||
#[description = "Channel or user mentions to set the reminder for"] channels: Option<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"]
|
#[description = "(Patreon only) Time to wait before repeating the reminder. Leave blank for one-shot reminder"]
|
||||||
interval: Option<String>,
|
interval: Option<String>,
|
||||||
@ -577,34 +593,22 @@ pub async fn remind(
|
|||||||
#[description = "Set the TTS flag on the reminder message, similar to the /tts command"]
|
#[description = "Set the TTS flag on the reminder message, similar to the /tts command"]
|
||||||
tts: Option<bool>,
|
tts: Option<bool>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
match content {
|
if content.is_empty() {
|
||||||
Some(content) => {
|
let data = ContentModal::execute(ctx).await?;
|
||||||
create_reminder(
|
|
||||||
Context::Application(ctx),
|
|
||||||
time,
|
|
||||||
content,
|
|
||||||
channels,
|
|
||||||
interval,
|
|
||||||
expires,
|
|
||||||
tts,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
None => {
|
create_reminder(
|
||||||
let data = ContentModal::execute(ctx).await?;
|
Context::Application(ctx),
|
||||||
|
time,
|
||||||
create_reminder(
|
data.content,
|
||||||
Context::Application(ctx),
|
channels,
|
||||||
time,
|
interval,
|
||||||
data.content,
|
expires,
|
||||||
channels,
|
tts,
|
||||||
interval,
|
)
|
||||||
expires,
|
.await
|
||||||
tts,
|
} else {
|
||||||
)
|
create_reminder(Context::Application(ctx), time, content, channels, interval, expires, tts)
|
||||||
.await
|
.await
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user