Support sending reminders to threads

This commit is contained in:
jude
2024-03-03 13:04:50 +00:00
parent dcee9e0d2a
commit 6f0bdf9852
3 changed files with 91 additions and 58 deletions

View File

@ -13,7 +13,7 @@ use chrono_tz::Tz;
use poise::{
serenity_prelude::{
model::id::{ChannelId, GuildId, UserId},
ButtonStyle, Cache, CreateActionRow, CreateButton, CreateEmbed, ReactionType,
ButtonStyle, Cache, ChannelType, CreateActionRow, CreateButton, CreateEmbed, ReactionType,
},
CreateReply,
};
@ -482,12 +482,23 @@ pub 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() {
let channel_with_threads = ChannelWithThread {
channel_id: ctx.channel_id().get(),
thread_id: None,
};
vec![ReminderScope::Channel(channel_with_threads)]
if let Some(channel) = ctx.guild_channel().await {
if channel.kind == ChannelType::PublicThread
|| channel.kind == ChannelType::PrivateThread
{
let parent = channel.parent_id.unwrap();
let channel_with_threads = ChannelWithThread {
channel_id: parent.get(),
thread_id: Some(ctx.channel_id().get()),
};
vec![ReminderScope::Channel(channel_with_threads)]
} else {
let channel_with_threads = ChannelWithThread {
channel_id: ctx.channel_id().get(),
thread_id: None,
};
vec![ReminderScope::Channel(channel_with_threads)]
}
} else {
vec![ReminderScope::User(ctx.author().id.get())]
}