aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris <[email protected]>2019-01-27 10:44:11 -0500
committerRapptz <[email protected]>2019-01-29 06:50:18 -0500
commit1222bce271cf736b4db8c1eecb2823edd22f85dc (patch)
tree2dcd08caf946e4dbc21f52d905ff5714c0326dc4
parentAdded support for comparing PermissionOverwrites (diff)
downloaddiscord.py-1222bce271cf736b4db8c1eecb2823edd22f85dc.tar.xz
discord.py-1222bce271cf736b4db8c1eecb2823edd22f85dc.zip
Add CategoryChannel.text_channels and voice_channels
-rw-r--r--discord/channel.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 6a630388..045d1624 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -624,6 +624,24 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
ret.sort(key=comparator)
return ret
+ @property
+ def text_channels(self):
+ """List[:class:`TextChannel`]: Returns the text channels that are under this category."""
+ ret = [c for c in self.guild.channels
+ if c.category_id == self.id
+ and isinstance(c, TextChannel)]
+ ret.sort(key=lambda c: (c.position, c.id))
+ return ret
+
+ @property
+ def voice_channels(self):
+ """List[:class:`VoiceChannel`]: Returns the text channels that are under this category."""
+ ret = [c for c in self.guild.channels
+ if c.category_id == self.id
+ and isinstance(c, VoiceChannel)]
+ ret.sort(key=lambda c: (c.position, c.id))
+ return ret
+
class DMChannel(discord.abc.Messageable, Hashable):
"""Represents a Discord direct message channel.