From bc6e00e15b8dc0bdeb99468773ea17d2e78d53c4 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 21 Jun 2023 22:46:53 +0200 Subject: [PATCH] feat: remove thread introductions --- src/events/mod.rs | 9 --------- src/events/thread_create.rs | 32 -------------------------------- src/model/application.rs | 15 +++++++-------- 3 files changed, 7 insertions(+), 49 deletions(-) delete mode 100644 src/events/thread_create.rs diff --git a/src/events/mod.rs b/src/events/mod.rs index c12abf3..f0d1bb9 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -105,13 +105,4 @@ impl serenity::EventHandler for Handler>> { }) .await; } - - async fn thread_create(&self, ctx: serenity::Context, thread: serenity::GuildChannel) { - thread_create::thread_create(&ctx, &thread).await; - - self.dispatch_poise_event(&ctx, &poise::Event::ThreadCreate { - thread, - }) - .await; - } } diff --git a/src/events/thread_create.rs b/src/events/thread_create.rs deleted file mode 100644 index 4a8266b..0000000 --- a/src/events/thread_create.rs +++ /dev/null @@ -1,32 +0,0 @@ -use tracing::{debug, error}; - -use super::*; -use crate::utils::bot::get_data_lock; - -pub async fn thread_create(ctx: &serenity::Context, thread: &serenity::GuildChannel) { - if thread.member.is_some() { - debug!("Thread was joined. Block dispatch."); - return; - } - - debug!("Thread created: {:?}", thread); - - let data_lock = get_data_lock(ctx).await; - let configuration_lock = data_lock.read().await; - - let thread_introductions = &configuration_lock.configuration.thread_introductions; - - if let Some(introducer) = thread_introductions.iter().find(|introducer| { - introducer - .channels - .iter() - .any(|channel_id| *channel_id == thread.parent_id.unwrap().0) - }) { - if let Err(why) = thread - .say(&ctx.http, &introducer.response.message.as_ref().unwrap()) - .await - { - error!("Error sending message: {:?}", why); - } - } -} diff --git a/src/model/application.rs b/src/model/application.rs index 6e2ca32..b4127f7 100644 --- a/src/model/application.rs +++ b/src/model/application.rs @@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize}; pub struct Configuration { pub general: General, pub administrators: Administrators, - pub thread_introductions: Vec, pub message_responses: Vec, } @@ -66,7 +65,6 @@ impl Configuration { pub struct General { pub embed_color: i32, pub mute: Mute, - pub media_channels: Vec, pub logging_channel: u64, } @@ -81,18 +79,19 @@ pub struct Administrators { pub users: Vec, } -#[derive(Serialize, Deserialize)] -pub struct Introduction { - pub channels: Vec, - pub response: Response, -} - #[derive(Serialize, Deserialize)] pub struct MessageResponse { pub includes: Option, pub excludes: Option, pub condition: Option, pub response: Response, + pub thread_options: Option, +} + +#[derive(Serialize, Deserialize)] +pub struct ThreadOptions { + pub close_on_response: bool, + pub lock_on_response: bool, } #[derive(Serialize, Deserialize)]