From 92dd72aa868fa8c701c716f3ec0976412962397c Mon Sep 17 00:00:00 2001 From: Victor Mignot Date: Wed, 7 Jun 2023 23:44:07 +0200 Subject: [PATCH] Fix notification issue when pinging users --- src/discord/commands/tag_notify.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/discord/commands/tag_notify.rs b/src/discord/commands/tag_notify.rs index 40f602e..dc77ca6 100644 --- a/src/discord/commands/tag_notify.rs +++ b/src/discord/commands/tag_notify.rs @@ -126,22 +126,23 @@ impl BotCommand for TagNotifyCommand { answer.push_str(user.as_str()); } - let mut response = match self.interaction.get_interaction_response(&context).await { + let response = match self.interaction.get_interaction_response(&context).await { Ok(r) => Ok(r), Err(_e) => Err(CommandExecutionError::ContextRetrievalError( "Failed to fetch initial interaction response".to_string(), )), }?; - response.delete_reactions(&context).await.map_err(|_e| { + response.delete(&context).await.map_err(|_e| { CommandExecutionError::DiscordAPICallError( - "Failed to remove reactions from initial response".to_string(), + "Failed to remove the embed message".to_string(), ) })?; - response - .edit(&context, |msg| { - msg.suppress_embeds(true); + // We have to create a new message as editing the original response will not notify + // the pinged users + self.interaction + .create_followup_message(&context, |msg| { msg.content(if answer.is_empty() { "Nobody to ping for your selection".to_string() } else { @@ -151,7 +152,7 @@ impl BotCommand for TagNotifyCommand { .await .map_err(|_e| { CommandExecutionError::DiscordAPICallError( - "Failed to edit content of the original response message".to_string(), + "Failed to create a new message to ping users".to_string(), ) })?; } else {