Function serenity::utils::parse_channel[][src]

pub fn parse_channel(mention: impl AsRef<str>) -> Option<u64>
Expand description

Retrieves an Id from a channel mention.

If the channel mention is invalid, then None is returned.

Examples

Retrieving an Id from a valid Channel mention:

use serenity::utils::parse_channel;

assert_eq!(parse_channel("<#81384788765712384>"), Some(81384788765712384));

Asserting that an invalid channel mention returns None:

use serenity::utils::parse_channel;

assert!(parse_channel("<#!81384788765712384>").is_none());
assert!(parse_channel("<#81384788765712384").is_none());