feat: remove thread introductions

This commit is contained in:
oSumAtrIX 2023-06-21 22:46:53 +02:00
parent 83c14c9a19
commit bc6e00e15b
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 7 additions and 49 deletions

View File

@ -105,13 +105,4 @@ impl serenity::EventHandler for Handler<Arc<RwLock<Data>>> {
})
.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;
}
}

View File

@ -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);
}
}
}

View File

@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
pub struct Configuration {
pub general: General,
pub administrators: Administrators,
pub thread_introductions: Vec<Introduction>,
pub message_responses: Vec<MessageResponse>,
}
@ -66,7 +65,6 @@ impl Configuration {
pub struct General {
pub embed_color: i32,
pub mute: Mute,
pub media_channels: Vec<u64>,
pub logging_channel: u64,
}
@ -81,18 +79,19 @@ pub struct Administrators {
pub users: Vec<u64>,
}
#[derive(Serialize, Deserialize)]
pub struct Introduction {
pub channels: Vec<u64>,
pub response: Response,
}
#[derive(Serialize, Deserialize)]
pub struct MessageResponse {
pub includes: Option<Includes>,
pub excludes: Option<Excludes>,
pub condition: Option<Condition>,
pub response: Response,
pub thread_options: Option<ThreadOptions>,
}
#[derive(Serialize, Deserialize)]
pub struct ThreadOptions {
pub close_on_response: bool,
pub lock_on_response: bool,
}
#[derive(Serialize, Deserialize)]