Make users only pinged once when using notify
This commit is contained in:
parent
1583bfb8dd
commit
9e171efd4c
|
@ -1,4 +1,4 @@
|
||||||
use std::sync::Arc;
|
use std::{collections::HashSet, sync::Arc};
|
||||||
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ impl BotCommand for TagNotifyCommand {
|
||||||
let user_selection = selector.get_user_selection().await?;
|
let user_selection = selector.get_user_selection().await?;
|
||||||
|
|
||||||
if let Some(selection) = user_selection {
|
if let Some(selection) = user_selection {
|
||||||
|
let mut users_to_ping: HashSet<String> = HashSet::new();
|
||||||
let mut answer = String::new();
|
let mut answer = String::new();
|
||||||
for selected_tag in selection {
|
for selected_tag in selection {
|
||||||
let t = match guild.tags.iter().find(|s| s.name == selected_tag) {
|
let t = match guild.tags.iter().find(|s| s.name == selected_tag) {
|
||||||
|
@ -112,7 +113,7 @@ impl BotCommand for TagNotifyCommand {
|
||||||
match user_id.parse::<u64>() {
|
match user_id.parse::<u64>() {
|
||||||
Ok(id) => match &UserId(id).to_user(&context).await {
|
Ok(id) => match &UserId(id).to_user(&context).await {
|
||||||
Ok(e) => {
|
Ok(e) => {
|
||||||
answer += &e.mention().to_string();
|
users_to_ping.insert(e.mention().to_string());
|
||||||
}
|
}
|
||||||
Err(_e) => {}
|
Err(_e) => {}
|
||||||
},
|
},
|
||||||
|
@ -120,6 +121,11 @@ impl BotCommand for TagNotifyCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for user in users_to_ping {
|
||||||
|
answer.push_str(user.as_str());
|
||||||
|
}
|
||||||
|
|
||||||
let mut response = match self.interaction.get_interaction_response(&context).await {
|
let mut response = match self.interaction.get_interaction_response(&context).await {
|
||||||
Ok(r) => Ok(r),
|
Ok(r) => Ok(r),
|
||||||
Err(_e) => Err(CommandExecutionError::ContextRetrievalError(
|
Err(_e) => Err(CommandExecutionError::ContextRetrievalError(
|
||||||
|
|
Loading…
Reference in a new issue