diff options
| author | Rapptz <[email protected]> | 2015-12-15 19:59:41 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-15 19:59:41 -0500 |
| commit | 42c67e36058cb7d45a78de0da0819aed394c51a3 (patch) | |
| tree | fd7359456efdbf741a4054724844f75bb8b9f1a5 | |
| parent | Fix GUILD_ROLE_DELETE triggering ValueError. (diff) | |
| download | discord.py-42c67e36058cb7d45a78de0da0819aed394c51a3.tar.xz discord.py-42c67e36058cb7d45a78de0da0819aed394c51a3.zip | |
Add a way to get bans from a server.
| -rw-r--r-- | discord/client.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index 90fd5f1d..970fb302 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1632,6 +1632,40 @@ class Client: yield from utils._verify_successful_response(r) yield from r.release() + @asyncio.coroutine + def get_bans(self, server): + """|coro| + + Retrieves all the :class:`User`s that are banned from the specified + server. + + You must have proper permissions to get this information. + + Parameters + ---------- + server : :class:`Server` + The server to get ban information from. + + Raises + ------- + Forbidden + You do not have proper permissions to get the information. + HTTPException + An error occurred while fetching the information. + + Returns + -------- + list + A list of :class:`User` that have been banned. + """ + + url = '{0}/{1.id}/bans'.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 [User(**user['user']) for user in data] + # Invite management @asyncio.coroutine |