Function serenity::utils::parse_invite[][src]

pub fn parse_invite(code: &str) -> &str
Expand description

Retrieves the “code” part of an invite out of a URL.

Examples

Two formats of invite codes are supported, both regardless of protocol prefix. Some examples:

  1. Retrieving the code from the URL "https://discord.gg/0cDvIgU2voY8RSYL":
use serenity::utils;

let url = "https://discord.gg/0cDvIgU2voY8RSYL";

assert_eq!(utils::parse_invite(url), "0cDvIgU2voY8RSYL");
  1. Retrieving the code from the URL "http://discord.com/invite/0cDvIgU2voY8RSYL":
use serenity::utils;

let url = "http://discord.com/invite/0cDvIgU2voY8RSYL";

assert_eq!(utils::parse_invite(url), "0cDvIgU2voY8RSYL");