mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-05-02 07:24:25 +02:00
feat: remove thread introductions
This commit is contained in:
parent
83c14c9a19
commit
bc6e00e15b
@ -105,13 +105,4 @@ impl serenity::EventHandler for Handler<Arc<RwLock<Data>>> {
|
|||||||
})
|
})
|
||||||
.await;
|
.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub struct Configuration {
|
pub struct Configuration {
|
||||||
pub general: General,
|
pub general: General,
|
||||||
pub administrators: Administrators,
|
pub administrators: Administrators,
|
||||||
pub thread_introductions: Vec<Introduction>,
|
|
||||||
pub message_responses: Vec<MessageResponse>,
|
pub message_responses: Vec<MessageResponse>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +65,6 @@ impl Configuration {
|
|||||||
pub struct General {
|
pub struct General {
|
||||||
pub embed_color: i32,
|
pub embed_color: i32,
|
||||||
pub mute: Mute,
|
pub mute: Mute,
|
||||||
pub media_channels: Vec<u64>,
|
|
||||||
pub logging_channel: u64,
|
pub logging_channel: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,18 +79,19 @@ pub struct Administrators {
|
|||||||
pub users: Vec<u64>,
|
pub users: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct Introduction {
|
|
||||||
pub channels: Vec<u64>,
|
|
||||||
pub response: Response,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct MessageResponse {
|
pub struct MessageResponse {
|
||||||
pub includes: Option<Includes>,
|
pub includes: Option<Includes>,
|
||||||
pub excludes: Option<Excludes>,
|
pub excludes: Option<Excludes>,
|
||||||
pub condition: Option<Condition>,
|
pub condition: Option<Condition>,
|
||||||
pub response: Response,
|
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)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user