diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/channel/channel_category.rs | 3 | ||||
| -rw-r--r-- | src/model/channel/group.rs | 4 | ||||
| -rw-r--r-- | src/model/channel/guild_channel.rs | 6 | ||||
| -rw-r--r-- | src/model/channel/mod.rs | 10 | ||||
| -rw-r--r-- | src/model/channel/private_channel.rs | 4 | ||||
| -rw-r--r-- | src/utils/mod.rs | 2 |
6 files changed, 7 insertions, 22 deletions
diff --git a/src/model/channel/channel_category.rs b/src/model/channel/channel_category.rs index 47b2281..f57910e 100644 --- a/src/model/channel/channel_category.rs +++ b/src/model/channel/channel_category.rs @@ -125,10 +125,9 @@ impl ChannelCategory { }) } - #[cfg(feature = "utils")] #[inline] pub fn is_nsfw(&self) -> bool { - self.kind == ChannelType::Text && (self.nsfw || serenity_utils::is_nsfw(&self.name)) + self.kind == ChannelType::Text && self.nsfw } /// Returns the name of the category. diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs index ad16fa0..e6946df 100644 --- a/src/model/channel/group.rs +++ b/src/model/channel/group.rs @@ -174,12 +174,8 @@ impl Group { /// Determines if the channel is NSFW. /// - /// Refer to [`utils::is_nsfw`] for more details. - /// /// **Note**: This method is for consistency. This will always return /// `false`, due to groups not being considered NSFW. - /// - /// [`utils::is_nsfw`]: ../../utils/fn.is_nsfw.html #[inline] pub fn is_nsfw(&self) -> bool { false } diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index 3713004..c403b4b 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -386,18 +386,14 @@ impl GuildChannel { /// Determines if the channel is NSFW. /// - /// Refer to [`utils::is_nsfw`] for more details. - /// /// Only [text channels][`ChannelType::Text`] are taken into consideration /// as being NSFW. [voice channels][`ChannelType::Voice`] are never NSFW. /// /// [`ChannelType::Text`]: enum.ChannelType.html#variant.Text /// [`ChannelType::Voice`]: enum.ChannelType.html#variant.Voice - /// [`utils::is_nsfw`]: ../../utils/fn.is_nsfw.html - #[cfg(feature = "utils")] #[inline] pub fn is_nsfw(&self) -> bool { - self.kind == ChannelType::Text && (self.nsfw || serenity_utils::is_nsfw(&self.name)) + self.kind == ChannelType::Text && self.nsfw } /// Gets a message from the channel. diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 73e2ff3..bc4ea75 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -334,11 +334,7 @@ impl Channel { } /// Determines if the channel is NSFW. - /// - /// Refer to [`utils::is_nsfw`] for more details. - /// - /// [`utils::is_nsfw`]: ../../utils/fn.is_nsfw.html - #[cfg(all(feature = "model", feature = "utils"))] + #[cfg(feature = "model")] #[inline] pub fn is_nsfw(&self) -> bool { match *self { @@ -769,7 +765,7 @@ mod test { #[test] fn nsfw_checks() { let mut channel = guild_channel(); - assert!(channel.is_nsfw()); + assert!(!channel.is_nsfw()); channel.kind = ChannelType::Voice; assert!(!channel.is_nsfw()); @@ -778,7 +774,7 @@ mod test { assert!(!channel.is_nsfw()); channel.name = "nsfw".to_string(); - assert!(channel.is_nsfw()); + assert!(!channel.is_nsfw()); channel.kind = ChannelType::Voice; assert!(!channel.is_nsfw()); channel.kind = ChannelType::Text; diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs index 2657d3b..4d602c9 100644 --- a/src/model/channel/private_channel.rs +++ b/src/model/channel/private_channel.rs @@ -150,12 +150,8 @@ impl PrivateChannel { /// Determines if the channel is NSFW. /// - /// Refer to [`utils::is_nsfw`] for more details. - /// /// **Note**: This method is for consistency. This will always return /// `false`, due to DMs not being considered NSFW. - /// - /// [`utils::is_nsfw`]: ../../utils/fn.is_nsfw.html #[inline] pub fn is_nsfw(&self) -> bool { false } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 2d1df4a..7cd60cf 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -91,6 +91,7 @@ pub fn vecmap_to_json_map<K: PartialEq + ToString>(map: VecMap<K, Value>) -> Map /// /// assert!(!utils::is_nsfw("nsfwstuff")); /// ``` +#[deprecated(since = "0.5.10", note = "Discord no longer turns a channel NSFW based on its name.")] pub fn is_nsfw(name: &str) -> bool { name == "nsfw" || name.chars().count() > 5 && name.starts_with("nsfw-") } @@ -566,6 +567,7 @@ mod test { assert_eq!(parsed, ["a", "b c", "d", "e f", "g"]); } + #[allow(deprecated)] #[test] fn test_is_nsfw() { assert!(!is_nsfw("general")); |