mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
Audit log role add and removes are lists, not single item.
Breaking change. role -> roles and it's now a list.
This commit is contained in:
parent
d7153b1b5c
commit
7916878eb5
@ -121,10 +121,10 @@ class AuditLogChanges:
|
||||
|
||||
# special cases for role add/remove
|
||||
if attr == '$add':
|
||||
self._handle_role(self.before, self.after, entry, elem)
|
||||
self._handle_role(self.before, self.after, entry, elem['new_value'])
|
||||
continue
|
||||
elif attr == '$remove':
|
||||
self._handle_role(self.after, self.before, entry, elem)
|
||||
self._handle_role(self.after, self.before, entry, elem['new_value'])
|
||||
continue
|
||||
|
||||
transformer = self.TRANSFORMERS.get(attr)
|
||||
@ -157,17 +157,22 @@ class AuditLogChanges:
|
||||
self.before.color = self.before.colour
|
||||
|
||||
def _handle_role(self, first, second, entry, elem):
|
||||
setattr(first, 'role', None)
|
||||
setattr(first, 'roles', None)
|
||||
|
||||
# TODO: partial data?
|
||||
role_id = int(elem['id'])
|
||||
role = utils.find(lambda r: r.id == role_id, entry.guild.roles)
|
||||
data = []
|
||||
roles = entry.guild.roles
|
||||
|
||||
if role is None:
|
||||
role = discord.Object(id=role_id)
|
||||
role.name = elem['name']
|
||||
for e in elem:
|
||||
role_id = int(e['id'])
|
||||
role = utils.find(lambda r: r.id == role_id, roles)
|
||||
|
||||
setattr(second, 'role', role)
|
||||
if role is None:
|
||||
role = discord.Object(id=role_id)
|
||||
role.name = e['name']
|
||||
|
||||
data.append(role)
|
||||
|
||||
setattr(second, 'roles', data)
|
||||
|
||||
class AuditLogEntry:
|
||||
"""Represents an Audit Log entry.
|
||||
|
@ -915,7 +915,7 @@ All enumerations are subclasses of `enum`_.
|
||||
|
||||
Possible attributes for :class:`AuditLogDiff`:
|
||||
|
||||
- :attr:`~AuditLogDiff.role`
|
||||
- :attr:`~AuditLogDiff.roles`
|
||||
|
||||
.. attribute:: role_create
|
||||
|
||||
@ -1375,12 +1375,12 @@ this goal, it must make use of a couple of data classes that aid in this goal.
|
||||
a ``type`` attribute set to either ``'role'`` or ``'member'`` to help
|
||||
decide what type of ID it is.
|
||||
|
||||
.. attribute:: role
|
||||
.. attribute:: roles
|
||||
|
||||
*Union[:class:`Role`, :class:`Object`]* – A role being added or removed
|
||||
*List[Union[:class:`Role`, :class:`Object`]]* – A list of roles being added or removed
|
||||
from a member.
|
||||
|
||||
If the role is not found then it is a :class:`Object` with the ID being
|
||||
If a role is not found then it is a :class:`Object` with the ID being
|
||||
filled in.
|
||||
|
||||
.. attribute:: nick
|
||||
|
Loading…
x
Reference in New Issue
Block a user