Fix notification issue when pinging users

This commit is contained in:
Victor Mignot 2023-06-07 23:44:07 +02:00
parent c2954dda9c
commit 92dd72aa86
No known key found for this signature in database
GPG key ID: FFE4EF056FB5E0D0

View file

@ -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 {