mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Add support for guild news channels.
This commit is contained in:
parent
e87ca143d3
commit
5ea84fb971
@ -85,11 +85,13 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('name', 'id', 'guild', 'topic', '_state', 'nsfw',
|
__slots__ = ('name', 'id', 'guild', 'topic', '_state', 'nsfw',
|
||||||
'category_id', 'position', 'slowmode_delay', '_overwrites')
|
'category_id', 'position', 'slowmode_delay', '_overwrites',
|
||||||
|
'_type')
|
||||||
|
|
||||||
def __init__(self, *, state, guild, data):
|
def __init__(self, *, state, guild, data):
|
||||||
self._state = state
|
self._state = state
|
||||||
self.id = int(data['id'])
|
self.id = int(data['id'])
|
||||||
|
self._type = data['type']
|
||||||
self._update(guild, data)
|
self._update(guild, data)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -129,6 +131,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
n = self.name
|
n = self.name
|
||||||
return self.nsfw or n == 'nsfw' or n[:5] == 'nsfw-'
|
return self.nsfw or n == 'nsfw' or n[:5] == 'nsfw-'
|
||||||
|
|
||||||
|
def is_news(self):
|
||||||
|
"""Checks if the channel is a news channel."""
|
||||||
|
return self._type == ChannelType.news.value
|
||||||
|
|
||||||
async def edit(self, *, reason=None, **options):
|
async def edit(self, *, reason=None, **options):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
@ -954,5 +960,7 @@ def _channel_factory(channel_type):
|
|||||||
return CategoryChannel, value
|
return CategoryChannel, value
|
||||||
elif value is ChannelType.group:
|
elif value is ChannelType.group:
|
||||||
return GroupChannel, value
|
return GroupChannel, value
|
||||||
|
elif value is ChannelType.news:
|
||||||
|
return TextChannel, value
|
||||||
else:
|
else:
|
||||||
return None, value
|
return None, value
|
||||||
|
@ -38,6 +38,7 @@ class ChannelType(Enum):
|
|||||||
voice = 2
|
voice = 2
|
||||||
group = 3
|
group = 3
|
||||||
category = 4
|
category = 4
|
||||||
|
news = 5
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -675,6 +675,9 @@ All enumerations are subclasses of `enum`_.
|
|||||||
.. attribute:: group
|
.. attribute:: group
|
||||||
|
|
||||||
A private group text channel.
|
A private group text channel.
|
||||||
|
.. attribute:: news
|
||||||
|
|
||||||
|
A guild news channel.
|
||||||
|
|
||||||
.. class:: MessageType
|
.. class:: MessageType
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user