feat: remove media channels

This commit is contained in:
oSumAtrIX 2023-06-21 21:38:43 +02:00
parent 895f3c19d3
commit 26c3c5fedc
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 2 additions and 44 deletions

View File

@ -1,15 +1,8 @@
use super::*;
use crate::utils::code_embed::utils::code_preview;
use crate::utils::media_channel::handle_media_channel;
use crate::utils::message_response::handle_message_response;
pub async fn message_create(ctx: &serenity::Context, new_message: &serenity::Message) {
let is_media_channel = handle_media_channel(ctx, new_message).await;
if is_media_channel {
return;
};
tokio::join!(
handle_message_response(ctx, new_message),
code_preview(ctx, new_message)

View File

@ -1,34 +0,0 @@
use tracing::error;
use super::bot::get_data_lock;
use super::*;
pub async fn handle_media_channel(
ctx: &serenity::Context,
new_message: &serenity::Message,
) -> bool {
let current_channel = new_message.channel_id.0;
let data_lock = get_data_lock(ctx).await;
let configuration = &data_lock.read().await.configuration;
let is_media_channel = configuration
.general
.media_channels
.iter()
.any(|&channel| channel == current_channel);
let is_admin = configuration
.administrators
.users
.contains(&new_message.author.id.0);
if is_media_channel && new_message.attachments.is_empty() && !is_admin {
if let Err(why) = new_message.delete(&ctx.http).await {
error!("Error deleting message: {:?}", why);
}
}
is_media_channel
}

View File

@ -1,13 +1,12 @@
use chrono::Duration;
use poise::serenity_prelude::{self as serenity, Member, RoleId};
pub mod message_response;
pub mod bot;
pub mod code_embed;
pub mod decancer;
pub mod message;
pub mod macros;
pub mod media_channel;
pub mod message;
pub mod message_response;
pub mod moderation;
pub mod poll;