mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-07 02:21:54 +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
|
# special cases for role add/remove
|
||||||
if attr == '$add':
|
if attr == '$add':
|
||||||
self._handle_role(self.before, self.after, entry, elem)
|
self._handle_role(self.before, self.after, entry, elem['new_value'])
|
||||||
continue
|
continue
|
||||||
elif attr == '$remove':
|
elif attr == '$remove':
|
||||||
self._handle_role(self.after, self.before, entry, elem)
|
self._handle_role(self.after, self.before, entry, elem['new_value'])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
transformer = self.TRANSFORMERS.get(attr)
|
transformer = self.TRANSFORMERS.get(attr)
|
||||||
@ -157,17 +157,22 @@ class AuditLogChanges:
|
|||||||
self.before.color = self.before.colour
|
self.before.color = self.before.colour
|
||||||
|
|
||||||
def _handle_role(self, first, second, entry, elem):
|
def _handle_role(self, first, second, entry, elem):
|
||||||
setattr(first, 'role', None)
|
setattr(first, 'roles', None)
|
||||||
|
|
||||||
# TODO: partial data?
|
data = []
|
||||||
role_id = int(elem['id'])
|
roles = entry.guild.roles
|
||||||
role = utils.find(lambda r: r.id == role_id, entry.guild.roles)
|
|
||||||
|
|
||||||
if role is None:
|
for e in elem:
|
||||||
role = discord.Object(id=role_id)
|
role_id = int(e['id'])
|
||||||
role.name = elem['name']
|
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:
|
class AuditLogEntry:
|
||||||
"""Represents an Audit Log entry.
|
"""Represents an Audit Log entry.
|
||||||
|
@ -915,7 +915,7 @@ All enumerations are subclasses of `enum`_.
|
|||||||
|
|
||||||
Possible attributes for :class:`AuditLogDiff`:
|
Possible attributes for :class:`AuditLogDiff`:
|
||||||
|
|
||||||
- :attr:`~AuditLogDiff.role`
|
- :attr:`~AuditLogDiff.roles`
|
||||||
|
|
||||||
.. attribute:: role_create
|
.. 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
|
a ``type`` attribute set to either ``'role'`` or ``'member'`` to help
|
||||||
decide what type of ID it is.
|
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.
|
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.
|
filled in.
|
||||||
|
|
||||||
.. attribute:: nick
|
.. attribute:: nick
|
||||||
|
Loading…
x
Reference in New Issue
Block a user