Add webhook support.

Allows for usage of either `requests` and `aiohttp` when used in
"Standalone" mode.

Fixes #704
This commit is contained in:
Rapptz
2017-08-21 01:54:33 -04:00
parent deaba1f5ab
commit 37b0fdb898
10 changed files with 813 additions and 7 deletions

View File

@ -36,6 +36,7 @@ from .http import HTTPClient
from .state import ConnectionState
from . import utils, compat
from .backoff import ExponentialBackoff
from .webhook import Webhook
import asyncio
import aiohttp
@ -1010,3 +1011,26 @@ class Client:
mutual_guilds=mutual_guilds,
user=User(data=user, state=state),
connected_accounts=data['connected_accounts'])
@asyncio.coroutine
def get_webhook_info(self, webhook_id):
"""|coro|
Retrieves a :class:`Webhook` with the specified ID.
Raises
--------
HTTPException
Retrieving the webhook failed.
NotFound
Invalid webhook ID.
Forbidden
You do not have permission to fetch this webhook.
Returns
---------
:class:`Webhook`
The webhook you requested.
"""
data = yield from self.http.get_webhook(webhook_id)
return Webhook.from_state(data, state=self._connection)