diff options
| author | Rapptz <[email protected]> | 2019-03-08 21:40:43 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-03-08 21:40:43 -0500 |
| commit | 5ea84fb971d736ed1faa7c446467c4757ef91ee5 (patch) | |
| tree | ba35d7bec907077426db44070680c14370eb1443 | |
| parent | Bump websockets version to 7.0 (diff) | |
| download | discord.py-5ea84fb971d736ed1faa7c446467c4757ef91ee5.tar.xz discord.py-5ea84fb971d736ed1faa7c446467c4757ef91ee5.zip | |
Add support for guild news channels.
| -rw-r--r-- | discord/channel.py | 12 | ||||
| -rw-r--r-- | discord/enums.py | 1 | ||||
| -rw-r--r-- | docs/api.rst | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/discord/channel.py b/discord/channel.py index ef4087c5..84bee3a6 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -85,11 +85,13 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): """ __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): self._state = state self.id = int(data['id']) + self._type = data['type'] self._update(guild, data) def __repr__(self): @@ -129,6 +131,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): n = self.name 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): """|coro| @@ -460,7 +466,7 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable): if member is not None: ret.append(member) return ret - + def permissions_for(self, member): base = super().permissions_for(member) @@ -954,5 +960,7 @@ def _channel_factory(channel_type): return CategoryChannel, value elif value is ChannelType.group: return GroupChannel, value + elif value is ChannelType.news: + return TextChannel, value else: return None, value diff --git a/discord/enums.py b/discord/enums.py index 9e6ec3e6..cfe475c6 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -38,6 +38,7 @@ class ChannelType(Enum): voice = 2 group = 3 category = 4 + news = 5 def __str__(self): return self.name diff --git a/docs/api.rst b/docs/api.rst index 45baab54..b80ee139 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -675,6 +675,9 @@ All enumerations are subclasses of `enum`_. .. attribute:: group A private group text channel. + .. attribute:: news + + A guild news channel. .. class:: MessageType |