Function parse_user_tag

Source
pub fn parse_user_tag(s: &str) -> Option<(&str, Option<NonZeroU16>)>
Expand description

Retrieves the username and discriminator out of a user tag (name#discrim). In order to accomodate next gen Discord usernames, this will also accept name style tags.

If the user tag is invalid, None is returned.

ยงExamples

use std::num::NonZeroU16;

use serenity::utils::parse_user_tag;

assert_eq!(parse_user_tag("kangalioo#9108"), Some(("kangalioo", NonZeroU16::new(9108))));
assert_eq!(parse_user_tag("kangalioo#10108"), None);
assert_eq!(parse_user_tag("kangalioo"), Some(("kangalioo", None)));