|
1 | 1 | use crate::prelude::config::*; |
2 | 2 | use crate::prelude::db::*; |
3 | | -use serenity::all::{ChannelId, CommandInteraction, Context, EditChannel, GuildId, Message}; |
| 3 | +use crate::prelude::utils::*; |
| 4 | +use serenity::all::{ChannelId, CommandInteraction, Context, EditChannel, GuildChannel, GuildId, Message}; |
| 5 | +use crate::errors::{ModmailError, ModmailResult}; |
4 | 6 |
|
5 | 7 | pub async fn is_in_thread(msg: &Message, pool: &sqlx::SqlitePool) -> bool { |
6 | 8 | let channel_id = msg.channel_id.to_string(); |
@@ -46,21 +48,27 @@ pub async fn move_channel_to_category_by_msg( |
46 | 48 | ctx: &Context, |
47 | 49 | msg: &Message, |
48 | 50 | category_id: ChannelId, |
49 | | -) -> Result<serenity::model::channel::GuildChannel, serenity::Error> { |
| 51 | +) -> ModmailResult<GuildChannel> { |
| 52 | + let permissions = get_category_permissions_overwrites(ctx, category_id).await?; |
| 53 | + |
50 | 54 | msg.channel_id |
51 | | - .edit(&ctx.http, EditChannel::new().category(category_id)) |
| 55 | + .edit(&ctx.http, EditChannel::new().category(category_id).permissions(permissions)) |
52 | 56 | .await |
| 57 | + .map_err(ModmailError::from) |
53 | 58 | } |
54 | 59 |
|
55 | 60 | pub async fn move_channel_to_category_by_command_option( |
56 | 61 | ctx: &Context, |
57 | 62 | command: &CommandInteraction, |
58 | 63 | category_id: ChannelId, |
59 | | -) -> Result<serenity::model::channel::GuildChannel, serenity::Error> { |
| 64 | +) -> ModmailResult<GuildChannel> { |
| 65 | + let permissions = get_category_permissions_overwrites(ctx, category_id).await?; |
| 66 | + |
60 | 67 | command |
61 | 68 | .channel_id |
62 | | - .edit(&ctx.http, EditChannel::new().category(category_id)) |
| 69 | + .edit(&ctx.http, EditChannel::new().category(category_id).permissions(permissions)) |
63 | 70 | .await |
| 71 | + .map_err(ModmailError::from) |
64 | 72 | } |
65 | 73 |
|
66 | 74 | pub fn find_best_match_category( |
|
0 commit comments