pub fn parse_channel_mention(mention: &str) -> Option<ChannelId>
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::model::id::ChannelId;
use serenity::utils::parse_channel;
assert_eq!(parse_channel("<#81384788765712384>"), Some(ChannelId::new(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());