From 37b0fdb898a0f242f68d30abb6c58bd1a15a6524 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 21 Aug 2017 01:54:33 -0400 Subject: Add webhook support. Allows for usage of either `requests` and `aiohttp` when used in "Standalone" mode. Fixes #704 --- discord/guild.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'discord/guild.py') diff --git a/discord/guild.py b/discord/guild.py index 3f7b7270..5d7cb134 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -43,6 +43,7 @@ from .utils import valid_icon_size from .user import User from .invite import Invite from .iterators import AuditLogIterator +from .webhook import Webhook VALID_ICON_FORMATS = {"jpeg", "jpg", "webp", "png"} @@ -798,6 +799,28 @@ class Guild(Hashable): data = yield from self._state.http.prune_members(self.id, days, reason=reason) return data['pruned'] + @asyncio.coroutine + def webhooks(self): + """|coro| + + Gets the list of webhooks from this guild. + + Requires :attr:`~.Permissions.manage_webhooks` permissions. + + Raises + ------- + Forbidden + You don't have permissions to get the webhooks. + + Returns + -------- + List[:class:`Webhook`] + The webhooks for this guild. + """ + + data = yield from self._state.http.guild_webhooks(self.id) + return [Webhook.from_state(d, state=self._state) for d in data] + @asyncio.coroutine def estimate_pruned_members(self, *, days): """|coro| -- cgit v1.2.3