aboutsummaryrefslogtreecommitdiff
path: root/discord/channel.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-06-09 00:23:22 -0400
committerRapptz <[email protected]>2019-06-09 00:23:22 -0400
commit7e2da1c93b9db02b71e9f7a35c8a09679d97b0bb (patch)
treea420236ece4573b0f449323a0783d786a385b056 /discord/channel.py
parentReplace Enum with an internal one for significant speed improvements. (diff)
downloaddiscord.py-7e2da1c93b9db02b71e9f7a35c8a09679d97b0bb.tar.xz
discord.py-7e2da1c93b9db02b71e9f7a35c8a09679d97b0bb.zip
Publicly expose a type property for all channels.
Fix #2185
Diffstat (limited to 'discord/channel.py')
-rw-r--r--discord/channel.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 7415ad03..ae0eb4c3 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -134,6 +134,11 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
return self
@property
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return try_enum(ChannelType, self._type)
+
+ @property
def _sorting_bucket(self):
return ChannelType.text.value
@@ -516,8 +521,9 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
return self.guild.id, self.id
@property
- def _type(self):
- return ChannelType.voice.value
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return ChannelType.voice
def _update(self, guild, data):
self.guild = guild
@@ -660,8 +666,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
return ChannelType.category.value
@property
- def _type(self):
- return ChannelType.category.value
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return ChannelType.category
def is_nsfw(self):
"""Checks if the category is NSFW."""
@@ -819,8 +826,9 @@ class StoreChannel(discord.abc.GuildChannel, Hashable):
return ChannelType.text.value
@property
- def _type(self):
- return ChannelType.store.value
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return ChannelType.store
def permissions_for(self, member):
base = super().permissions_for(member)
@@ -928,8 +936,9 @@ class DMChannel(discord.abc.Messageable, Hashable):
return '<DMChannel id={0.id} recipient={0.recipient!r}>'.format(self)
@property
- def _type(self):
- return ChannelType.private.value
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return ChannelType.private
@property
def created_at(self):
@@ -1041,8 +1050,9 @@ class GroupChannel(discord.abc.Messageable, Hashable):
return '<GroupChannel id={0.id} name={0.name!r}>'.format(self)
@property
- def _type(self):
- return ChannelType.group.value
+ def type(self):
+ """:class:`ChannelType`: The channel's Discord type."""
+ return ChannelType.group
@property
def icon_url(self):