Function serenity::utils::is_nsfw[][src]

pub fn is_nsfw(name: &str) -> bool

Determines if a name is NSFW.

This checks that the name is either "nsfw" or, for names longer than that, is prefixed with "nsfw".

Examples

Check that a channel named "nsfw" is in fact NSFW:

use serenity::utils;

assert!(utils::is_nsfw("nsfw"));

Check that a channel named "cats" is not NSFW:

use serenity::utils;

assert!(!utils::is_nsfw("cats"));

Check that a channel named "nsfw-stuff" is NSFW:

use serenity::utils;

assert!(utils::is_nsfw("nsfw-stuff"));

Channels prefixed with "nsfw" but not the hyphen ('-') are not considered NSFW:

use serenity::utils;

assert!(!utils::is_nsfw("nsfwstuff"));