Function parse_message_url

Source
pub fn parse_message_url(s: &str) -> Option<(GuildId, ChannelId, MessageId)>
Expand description

Retrieves guild, channel, and message ID from a message URL.

If the URL is malformed, None is returned.

ยงExamples

use serenity::model::prelude::*;
use serenity::utils::parse_message_url;

assert_eq!(
    parse_message_url(
        "https://discord.com/channels/381880193251409931/381880193700069377/806164913558781963"
    ),
    Some((
        GuildId::new(381880193251409931),
        ChannelId::new(381880193700069377),
        MessageId::new(806164913558781963),
    )),
);
assert_eq!(
    parse_message_url(
        "https://canary.discord.com/channels/381880193251409931/381880193700069377/806164913558781963"
    ),
    Some((
        GuildId::new(381880193251409931),
        ChannelId::new(381880193700069377),
        MessageId::new(806164913558781963),
    )),
);
assert_eq!(parse_message_url("https://google.com"), None);