From 1ec74e7c5ad3d87afc54d4c5f43438d93837ca32 Mon Sep 17 00:00:00 2001 From: Gent Semaj Date: Mon, 6 Jan 2025 16:19:28 -0500 Subject: [PATCH] Mention (but don't ping) approver/denier --- src/main.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 92404fa..6342f6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,9 +9,9 @@ use ffmonitor::{Monitor, NameRequestEvent}; use poise::{ serenity_prelude::{ ActivityData, ChannelId, ClientBuilder, ComponentInteraction, - ComponentInteractionCollector, Context, CreateActionRow, CreateButton, - CreateInteractionResponse, CreateInteractionResponseMessage, CreateMessage, GatewayIntents, - GuildId, RoleId, User, + ComponentInteractionCollector, Context, CreateActionRow, CreateAllowedMentions, + CreateButton, CreateInteractionResponse, CreateInteractionResponseMessage, CreateMessage, + GatewayIntents, GuildId, Mention, RoleId, User, }, CreateReply, }; @@ -184,11 +184,17 @@ async fn handle_namereq_approve( let Some(channel) = globals.log_channel else { return Ok(()); }; - let msg = format!( + + let mention = Mention::from(user.id); + let content = format!( "Name request from Player {} **approved** :white_check_mark: by {}: {}", - namereq.player_uid, user, namereq.requested_name + namereq.player_uid, mention, namereq.requested_name ); - send_message(channel, &msg).await?; + let allowed_mentions = CreateAllowedMentions::default().empty_users(); // avoids ping + let msg = CreateMessage::default() + .content(content) + .allowed_mentions(allowed_mentions); + channel.send_message(http, msg).await?; Ok(()) } @@ -222,11 +228,17 @@ async fn handle_namereq_deny(globals: &Globals, interaction: &ComponentInteracti let Some(channel) = globals.log_channel else { return Ok(()); }; - let msg = format!( + + let mention = Mention::from(user.id); + let content = format!( "Name request from Player {} **denied** :no_entry: by {}: {}", - namereq.player_uid, user, namereq.requested_name + namereq.player_uid, mention, namereq.requested_name ); - send_message(channel, &msg).await?; + let allowed_mentions = CreateAllowedMentions::default().empty_users(); // avoids ping + let msg = CreateMessage::default() + .content(content) + .allowed_mentions(allowed_mentions); + channel.send_message(http, msg).await?; Ok(()) }