Implement new-style NSFW channels.
No idea how these will change in the future but this is barebones enough for now.
This commit is contained in:
parent
2e57fa6dfd
commit
6e0902ef57
@ -77,7 +77,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
top channel is position 0.
|
top channel is position 0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ( 'name', 'id', 'guild', 'topic', '_state',
|
__slots__ = ( 'name', 'id', 'guild', 'topic', '_state', 'nsfw',
|
||||||
'position', '_overwrites' )
|
'position', '_overwrites' )
|
||||||
|
|
||||||
def __init__(self, *, state, guild, data):
|
def __init__(self, *, state, guild, data):
|
||||||
@ -93,6 +93,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
self.name = data['name']
|
self.name = data['name']
|
||||||
self.topic = data.get('topic')
|
self.topic = data.get('topic')
|
||||||
self.position = data['position']
|
self.position = data['position']
|
||||||
|
self.nsfw = data.get('nsfw', False)
|
||||||
self._fill_overwrites(data)
|
self._fill_overwrites(data)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -117,7 +118,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
def is_nsfw(self):
|
def is_nsfw(self):
|
||||||
"""Checks if the channel is NSFW."""
|
"""Checks if the channel is NSFW."""
|
||||||
n = self.name
|
n = self.name
|
||||||
return n == 'nsfw' or n[:5] == 'nsfw-'
|
return self.nsfw or n == 'nsfw' or n[:5] == 'nsfw-'
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def edit(self, *, reason=None, **options):
|
def edit(self, *, reason=None, **options):
|
||||||
@ -136,6 +137,8 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
The new channel's topic.
|
The new channel's topic.
|
||||||
position: int
|
position: int
|
||||||
The new channel's position.
|
The new channel's position.
|
||||||
|
nsfw: bool
|
||||||
|
To mark the channel as NSFW or not.
|
||||||
reason: Optional[str]
|
reason: Optional[str]
|
||||||
The reason for editing this channel. Shows up on the audit log.
|
The reason for editing this channel. Shows up on the audit log.
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ class HTTPClient:
|
|||||||
|
|
||||||
def edit_channel(self, channel_id, *, reason=None, **options):
|
def edit_channel(self, channel_id, *, reason=None, **options):
|
||||||
r = Route('PATCH', '/channels/{channel_id}', channel_id=channel_id)
|
r = Route('PATCH', '/channels/{channel_id}', channel_id=channel_id)
|
||||||
valid_keys = ('name', 'topic', 'bitrate', 'user_limit', 'position')
|
valid_keys = ('name', 'topic', 'bitrate', 'nsfw', 'user_limit', 'position')
|
||||||
payload = {
|
payload = {
|
||||||
k: v for k, v in options.items() if k in valid_keys
|
k: v for k, v in options.items() if k in valid_keys
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user