mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-05-02 15:34:24 +02:00
feat: remove media channels
This commit is contained in:
parent
895f3c19d3
commit
26c3c5fedc
@ -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)
|
||||
|
@ -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
|
||||
}
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user