Partial thread support

This commit is contained in:
2023-05-11 15:02:26 +01:00
parent 6e831c8253
commit 523ab7f03a
4 changed files with 103 additions and 13 deletions

View File

@ -5,7 +5,8 @@ use chrono_tz::Tz;
use num_integer::Integer;
use poise::{
serenity_prelude::{
builder::CreateEmbed, component::ButtonStyle, model::channel::Channel, ReactionType,
builder::CreateEmbed, component::ButtonStyle, model::channel::Channel, ChannelType,
ReactionType,
},
CreateReply, Modal,
};
@ -664,10 +665,18 @@ async fn create_reminder(
let list = channels.map(|arg| parse_mention_list(&arg)).unwrap_or_default();
if list.is_empty() {
if ctx.guild_id().is_some() {
vec![ReminderScope::Channel(ctx.channel_id().0)]
} else {
vec![ReminderScope::User(ctx.author().id.0)]
let channel = ctx.channel_id().to_channel(&ctx.discord()).await?;
match channel.guild() {
Some(guild_channel) => {
if guild_channel.kind == ChannelType::PublicThread {
vec![ReminderScope::Thread(ctx.channel_id().0)]
} else {
vec![ReminderScope::Channel(ctx.channel_id().0)]
}
}
None => vec![ReminderScope::User(ctx.author().id.0)],
}
} else {
list
@ -815,6 +824,7 @@ fn create_response(
embed
}
// TODO process threads here
fn parse_mention_list(mentions: &str) -> Vec<ReminderScope> {
REGEX_CHANNEL_USER
.captures_iter(mentions)