Skip to main content

strip_bot_mention_prefix

Function strip_bot_mention_prefix 

Source
fn strip_bot_mention_prefix(content: &str, bot_id: UserId) -> Option<&str>
Expand description

Strips a leading <@ID> or <@!ID> mention of bot_id from content.

Returns None if the content (after leading whitespace) doesn’t start with either mention form. This runs on every message the bot sees, so it parses the mention’s ID and compares it numerically instead of formatting bot_id into a String to match against — the latter would allocate on every message regardless of whether it turns out to be a command.