new anti-ping-spam functionality

This commit is contained in:
2024-11-20 19:32:33 -05:00
parent c5a114540c
commit 9fd85e38fb
4 changed files with 63 additions and 3 deletions

13
src/ping_limit.rs Normal file
View File

@@ -0,0 +1,13 @@
use poise::serenity_prelude::*;
use regex::Regex;
pub fn extract_mentions(content: &str) -> Vec<UserId> {
// Define the regex pattern for user mentions
let re = Regex::new(r"<@(\d+)>").unwrap();
// Find all matches and capture the IDs
re.captures_iter(content)
.filter_map(|cap| cap.get(1).map(|id| id.as_str().parse().unwrap()))
.collect()
}