Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
[channel] add support for nsfw flag
Browse files Browse the repository at this point in the history
  • Loading branch information
b1naryth1ef committed Jul 13, 2017
1 parent 070bb65 commit 885a215
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion disco/types/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Channel(SlottedModel, Permissible):
position = Field(int)
bitrate = Field(int)
recipients = AutoDictField(User, 'id')
nsfw = Field(bool)
type = Field(enum(ChannelType))
overwrites = AutoDictField(PermissionOverwrite, 'id', alias='permission_overwrites')

Expand Down Expand Up @@ -187,7 +188,7 @@ def is_nsfw(self):
"""
Whether this channel is an NSFW channel.
"""
return self.type == ChannelType.GUILD_TEXT and NSFW_RE.match(self.name)
return self.type == ChannelType.GUILD_TEXT and (self.nsfw or NSFW_RE.match(self.name))

@property
def is_voice(self):
Expand Down Expand Up @@ -399,6 +400,13 @@ def set_position(self, position, reason=None):
"""
return self.client.api.channels_modify(self.id, position=position, reason=reason)

def set_nsfw(self, value, reason=None):
"""
Sets whether the channel is NSFW.
"""
assert (self.type == ChannelType.GUILD_TEXT)
return self.client.api.channels_modify(self.id, nsfw=value, reason=reason)

def set_bitrate(self, bitrate, reason=None):
"""
Sets the channels bitrate.
Expand Down

0 comments on commit 885a215

Please sign in to comment.