aboutsummaryrefslogtreecommitdiff
path: root/discord/guild.py
diff options
context:
space:
mode:
authorNCPlayz <[email protected]>2019-05-18 22:29:22 +0100
committerRapptz <[email protected]>2019-06-07 19:12:59 -0400
commitf7c6c5995daef14b4d471b6eaea5cb96305bfc88 (patch)
tree89d0c932c9bf6a0713b285dddd95da09ef9ca0b8 /discord/guild.py
parentAdd support for system channel flags (diff)
downloaddiscord.py-f7c6c5995daef14b4d471b6eaea5cb96305bfc88.tar.xz
discord.py-f7c6c5995daef14b4d471b6eaea5cb96305bfc88.zip
Implementing GET '/channels/:id' & '/guilds/:id/channels'
Signed-off-by: NCPlayz <[email protected]>
Diffstat (limited to 'discord/guild.py')
-rw-r--r--discord/guild.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py
index fc8d22b9..f6a5e2c5 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -32,6 +32,7 @@ from .role import Role
from .member import Member, VoiceState
from .activity import create_activity
from .emoji import Emoji
+from .errors import InvalidData
from .permissions import PermissionOverwrite
from .colour import Colour
from .errors import InvalidArgument, ClientException
@@ -1104,6 +1105,41 @@ class Guild(Hashable):
fields['system_channel_flags'] = system_channel_flags.value
await http.edit_guild(self.id, reason=reason, **fields)
+ async def fetch_channels(self):
+ """|coro|
+
+ Retrieves all :class:`abc.GuildChannel` that the guild has.
+
+ .. note::
+
+ This method is an API call. For general usage, consider :attr:`channels` instead.
+
+ .. versionadded:: 1.2.0
+
+ Raises
+ -------
+ TypeError
+ An unknown channel type was received from Discord.
+ HTTPException
+ Retrieving the channels failed.
+
+ Returns
+ -------
+ List[:class:`abc.GuildChannel`]
+ All channels in the guild.
+ """
+ data = await self._state.http.get_all_guild_channels(self.id)
+
+ def convert(d):
+ factory, ch_type = _channel_factory(d['type'])
+ if factory is None:
+ raise InvalidData('Unknown channel type {type} for channel ID {id}.'.format_map(data))
+
+ channel = factory(guild=self, state=self._state, data=d)
+ return channel
+
+ return [convert(d) for d in data]
+
async def fetch_member(self, member_id):
"""|coro|