mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 00:07:51 +00:00
Fix Guild.bans to return a BanEntry object.
This commit is contained in:
parent
58fa5fdc9a
commit
6516932e67
@ -27,6 +27,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
import copy
|
||||
import asyncio
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from . import utils
|
||||
from .role import Role
|
||||
from .member import Member, VoiceState
|
||||
@ -41,6 +43,8 @@ from .mixins import Hashable
|
||||
from .user import User
|
||||
from .invite import Invite
|
||||
|
||||
BanEntry = namedtuple('BanEntry', 'reason user')
|
||||
|
||||
class Guild(Hashable):
|
||||
"""Represents a Discord guild.
|
||||
|
||||
@ -616,7 +620,12 @@ class Guild(Hashable):
|
||||
def bans(self):
|
||||
"""|coro|
|
||||
|
||||
Retrieves all the :class:`User`\s that are banned from the guild.
|
||||
Retrieves all the users that are banned from the guild.
|
||||
|
||||
This coroutine returns a list of BanEntry objects. Which is a
|
||||
namedtuple with a ``user`` field to denote the :class:`User`
|
||||
that got banned along with a ``reason`` field specifying
|
||||
why the user was banned that could be set to ``None``.
|
||||
|
||||
You must have :attr:`Permissions.ban_members` permission
|
||||
to get this information.
|
||||
@ -630,12 +639,14 @@ class Guild(Hashable):
|
||||
|
||||
Returns
|
||||
--------
|
||||
list
|
||||
A list of :class:`User` that have been banned.
|
||||
List[BanEntry]
|
||||
A list of BanEntry objects.
|
||||
"""
|
||||
|
||||
data = yield from self._state.http.get_bans(self.id)
|
||||
return [User(state=self._state, data=user) for user in data]
|
||||
return [BanEntry(user=User(state=self._state, data=e['user']),
|
||||
reason=e['reason'])
|
||||
for e in data]
|
||||
|
||||
@asyncio.coroutine
|
||||
def prune_members(self, *, days):
|
||||
|
Loading…
x
Reference in New Issue
Block a user