new anti-ping-spam functionality
This commit is contained in:
13
src/ping_limit.rs
Normal file
13
src/ping_limit.rs
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user