diff options
| author | acdenisSK <[email protected]> | 2017-07-18 22:55:20 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-18 22:55:20 +0200 |
| commit | b602805501df003d1925c2f0d0c80c2bac6d32a2 (patch) | |
| tree | 2417470772847dd27731d35e50958bbde4b93d59 /src | |
| parent | Fix event handler dispatching (diff) | |
| download | serenity-b602805501df003d1925c2f0d0c80c2bac6d32a2.tar.xz serenity-b602805501df003d1925c2f0d0c80c2bac6d32a2.zip | |
Implement the new way of knowing some channels as "nsfw"
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/channel/guild_channel.rs | 15 |
1 files changed, 14 insertions, 1 deletions
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<u64>, + /// 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. |