From b602805501df003d1925c2f0d0c80c2bac6d32a2 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Tue, 18 Jul 2017 22:55:20 +0200 Subject: Implement the new way of knowing some channels as "nsfw" --- src/model/channel/guild_channel.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index c7083d6..0217231 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -66,6 +66,19 @@ pub struct GuildChannel { /// /// **Note**: This is only available for voice channels. pub user_limit: Option, + /// Used to tell if the channel is not safe for work. + /// Note however, it's recommended to use [`is_nsfw`] as it's gonna be more accurate. + /// + /// [`is_nsfw`]: struct.GuildChannel.html#method.is_nsfw + + // This field can or can not be present sometimes, but if it isn't + // default to `false`. + #[serde(default = "nsfw_false")] + pub nsfw: bool, +} + +fn nsfw_false() -> bool { + false } #[cfg(feature="model")] @@ -373,7 +386,7 @@ impl GuildChannel { #[cfg(feature="utils")] #[inline] pub fn is_nsfw(&self) -> bool { - self.kind == ChannelType::Text && serenity_utils::is_nsfw(&self.name) + self.nsfw || self.name == "nsfw" || self.kind == ChannelType::Text && serenity_utils::is_nsfw(&self.name) } /// Gets a message from the channel. -- cgit v1.2.3