Revert "remove reactions from messages older than n days"
This reverts commit 94b12a1069
.
This commit is contained in:
parent
a51210289b
commit
ca7bacb5ac
9 changed files with 18 additions and 86 deletions
|
@ -1,39 +0,0 @@
|
|||
use crate::Data;
|
||||
|
||||
use chrono::Duration;
|
||||
use eyre::{Context as _, Result};
|
||||
use log::{debug, trace};
|
||||
use poise::serenity_prelude::{Context, Reaction, Timestamp};
|
||||
|
||||
pub async fn handle(ctx: &Context, reaction: &Reaction, data: &Data) -> Result<()> {
|
||||
let reaction_type = reaction.emoji.clone();
|
||||
let reactor = reaction.user_id;
|
||||
let message = reaction.message(ctx).await.wrap_err_with(|| {
|
||||
format!(
|
||||
"Couldn't get message {} from reaction! We won't be able to check if it's old",
|
||||
reaction.message_id
|
||||
)
|
||||
})?;
|
||||
|
||||
let time_sent = message.timestamp.to_utc();
|
||||
let age = Timestamp::now().signed_duration_since(time_sent);
|
||||
let max_days = Duration::days(data.config.discord.days_to_delete_reaction);
|
||||
|
||||
if age >= max_days {
|
||||
// NOTE: if we for some reason **didn't** get the user_id associated with the reaction,
|
||||
// this will clear **all** reactions of this type. this is intentional as older reactions
|
||||
// being removed > harmful reactions being kept
|
||||
debug!(
|
||||
"Removing reaction {reaction_type} from message {}",
|
||||
message.id
|
||||
);
|
||||
message.delete_reaction(ctx, reactor, reaction_type).await?;
|
||||
} else {
|
||||
trace!(
|
||||
"Keeping reaction {reaction_type} for message {}",
|
||||
message.id
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -5,7 +5,6 @@ use poise::serenity_prelude::{ActivityData, Context, FullEvent, OnlineStatus};
|
|||
use poise::FrameworkContext;
|
||||
|
||||
mod analyze_logs;
|
||||
mod block_reaction;
|
||||
mod delete_on_reaction;
|
||||
mod eta;
|
||||
mod expand_link;
|
||||
|
@ -74,8 +73,6 @@ pub async fn handle(
|
|||
add_reaction.message_id.to_string(),
|
||||
add_reaction.user_id.unwrap_or_default().to_string()
|
||||
);
|
||||
|
||||
block_reaction::handle(ctx, add_reaction, data).await?;
|
||||
delete_on_reaction::handle(ctx, add_reaction).await?;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue