aboutsummaryrefslogtreecommitdiff
path: root/discord/guild.py
diff options
context:
space:
mode:
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|