Add a way to get all active invites from a server.
This commit is contained in:
parent
42c67e3605
commit
00a98a76fd
@ -1772,6 +1772,47 @@ class Client:
|
|||||||
data['channel'] = channel
|
data['channel'] = channel
|
||||||
return Invite(**data)
|
return Invite(**data)
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def invites_from(self, server):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Returns a generator that yields all active instant invites from
|
||||||
|
a :class:`Server`.
|
||||||
|
|
||||||
|
You must have proper permissions to get this information.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
server : :class:`Server`
|
||||||
|
The server to get invites from.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
Forbidden
|
||||||
|
You do not have proper permissions to get the information.
|
||||||
|
HTTPException
|
||||||
|
An error occurred while fetching the information.
|
||||||
|
|
||||||
|
Yields
|
||||||
|
-------
|
||||||
|
:class:`Invite`
|
||||||
|
The invite with the message data parsed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def generator(data):
|
||||||
|
for invite in data:
|
||||||
|
channel = utils.get(server.channels, id=invite['channel']['id'])
|
||||||
|
invite['channel'] = channel
|
||||||
|
invite['server'] = server
|
||||||
|
yield Invite(**invite)
|
||||||
|
|
||||||
|
url = '{0}/{1.id}/invites'.format(endpoints.SERVERS, server)
|
||||||
|
resp = yield from aiohttp.get(url, headers=self.headers, loop=self.loop)
|
||||||
|
log.debug(request_logging_format.format(method='GET', response=resp))
|
||||||
|
yield from utils._verify_successful_response(resp)
|
||||||
|
data = yield from resp.json()
|
||||||
|
return generator(data)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def accept_invite(self, invite):
|
def accept_invite(self, invite):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user