diff options
| author | Rapptz <[email protected]> | 2015-12-17 17:39:30 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-17 17:39:30 -0500 |
| commit | 253e2b1f648f4b803affe28a8558380483fa9860 (patch) | |
| tree | 5621387de7e69b6cd686739cb8541d32cea4dda1 | |
| parent | Fix consistency issue with migrating page. (diff) | |
| download | discord.py-253e2b1f648f4b803affe28a8558380483fa9860.tar.xz discord.py-253e2b1f648f4b803affe28a8558380483fa9860.zip | |
Add way to delete messages after a user is banned.
Fixes #59.
| -rw-r--r-- | discord/client.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/discord/client.py b/discord/client.py index fb55039f..9483c5f9 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1153,7 +1153,7 @@ class Client: yield from response.release() @asyncio.coroutine - def ban(self, member): + def ban(self, member, delete_message_days=1): """|coro| Bans a :class:`Member` from the server they belong to. @@ -1168,6 +1168,9 @@ class Client: ----------- member : :class:`Member` The member to ban from their server. + delete_message_days : int + The number of days worth of messages to delete from the user + in the server. The minimum is 0 and the maximum is 7. Raises ------- @@ -1177,8 +1180,12 @@ class Client: Banning failed. """ + params = { + 'delete-message-days': delete_message_days + } + url = '{0}/{1.server.id}/bans/{1.id}'.format(endpoints.SERVERS, member) - response = yield from aiohttp.put(url, headers=self.headers, loop=self.loop) + response = yield from aiohttp.put(url, params=params, headers=self.headers, loop=self.loop) log.debug(request_logging_format.format(method='PUT', response=response)) yield from utils._verify_successful_response(response) yield from response.release() |