aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-07-18 22:55:20 +0200
committeracdenisSK <[email protected]>2017-07-18 22:55:20 +0200
commitb602805501df003d1925c2f0d0c80c2bac6d32a2 (patch)
tree2417470772847dd27731d35e50958bbde4b93d59
parentFix event handler dispatching (diff)
downloadserenity-b602805501df003d1925c2f0d0c80c2bac6d32a2.tar.xz
serenity-b602805501df003d1925c2f0d0c80c2bac6d32a2.zip
Implement the new way of knowing some channels as "nsfw"
-rw-r--r--src/model/channel/guild_channel.rs15
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.