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 copy
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .role import Role
|
from .role import Role
|
||||||
from .member import Member, VoiceState
|
from .member import Member, VoiceState
|
||||||
@ -41,6 +43,8 @@ from .mixins import Hashable
|
|||||||
from .user import User
|
from .user import User
|
||||||
from .invite import Invite
|
from .invite import Invite
|
||||||
|
|
||||||
|
BanEntry = namedtuple('BanEntry', 'reason user')
|
||||||
|
|
||||||
class Guild(Hashable):
|
class Guild(Hashable):
|
||||||
"""Represents a Discord guild.
|
"""Represents a Discord guild.
|
||||||
|
|
||||||
@ -616,7 +620,12 @@ class Guild(Hashable):
|
|||||||
def bans(self):
|
def bans(self):
|
||||||
"""|coro|
|
"""|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
|
You must have :attr:`Permissions.ban_members` permission
|
||||||
to get this information.
|
to get this information.
|
||||||
@ -630,12 +639,14 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
Returns
|
Returns
|
||||||
--------
|
--------
|
||||||
list
|
List[BanEntry]
|
||||||
A list of :class:`User` that have been banned.
|
A list of BanEntry objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data = yield from self._state.http.get_bans(self.id)
|
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
|
@asyncio.coroutine
|
||||||
def prune_members(self, *, days):
|
def prune_members(self, *, days):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user