diff options
| author | slice <[email protected]> | 2018-05-07 16:42:04 -0700 |
|---|---|---|
| committer | slice <[email protected]> | 2018-05-07 16:42:04 -0700 |
| commit | 9fe7776a33d5304964a44a28c5bcc9489066bf11 (patch) | |
| tree | 3e09d5c735b9c20cf148c30a91f840d38fc93caa /discord/guild.py | |
| parent | Filter null mentions when creating a Message. (diff) | |
| download | discord.py-9fe7776a33d5304964a44a28c5bcc9489066bf11.tar.xz discord.py-9fe7776a33d5304964a44a28c5bcc9489066bf11.zip | |
Add support for getting individual ban entries
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index 247523cc..165ca446 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -799,6 +799,36 @@ class Guild(Hashable): yield from http.edit_guild(self.id, reason=reason, **fields) + @asyncio.coroutine + def get_ban(self, user): + """|coro| + + Retrieves the :class:`BanEntry` for a user, which is a namedtuple + with a ``user`` and ``reason`` field. See :meth:`bans` for more + information. + + You must have :attr:`~Permissions.ban_members` permission + to get this information. + + Raises + ------ + Forbidden + You do not have proper permissions to get the information. + NotFound + This user is not banned. + HTTPException + An error occurred while fetching the information. + + Returns + ------- + BanEntry + The BanEntry object for the specified user. + """ + data = yield from self._state.http.get_ban(user.id, self.id) + return BanEntry( + user=User(state=self._state, data=data['user']), + reason=data['reason'] + ) @asyncio.coroutine def bans(self): |