feat: add message logger
This commit is contained in:
parent
8376c45c2d
commit
7e96bced41
3 changed files with 101 additions and 2 deletions
25
src/handlers/event/delete_on_reaction.rs
Normal file
25
src/handlers/event/delete_on_reaction.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use color_eyre::eyre::{Context as _, Result};
|
||||
use poise::serenity_prelude::{Context, InteractionType, Reaction};
|
||||
|
||||
pub async fn handle(ctx: &Context, reaction: &Reaction) -> Result<()> {
|
||||
let user = reaction
|
||||
.user(ctx)
|
||||
.await
|
||||
.wrap_err_with(|| "Couldn't fetch user from reaction!")?;
|
||||
|
||||
let message = reaction
|
||||
.message(ctx)
|
||||
.await
|
||||
.wrap_err_with(|| "Couldn't fetch message from reaction!")?;
|
||||
|
||||
if let Some(interaction) = &message.interaction {
|
||||
if interaction.kind == InteractionType::ApplicationCommand
|
||||
&& interaction.user == user
|
||||
&& reaction.emoji.unicode_eq("❌")
|
||||
{
|
||||
message.delete(ctx).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue