aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-05-06 16:24:14 -0400
committerRapptz <[email protected]>2017-05-06 16:39:47 -0400
commit7916878eb59cbf01e5beb55767e9e08fcfbfcff2 (patch)
treed8c12e9fb48ef5f99d388847f84b24b4526b3a72
parentReplace hasattr with try except in chunker. (diff)
downloaddiscord.py-7916878eb59cbf01e5beb55767e9e08fcfbfcff2.tar.xz
discord.py-7916878eb59cbf01e5beb55767e9e08fcfbfcff2.zip
Audit log role add and removes are lists, not single item.
Breaking change. role -> roles and it's now a list.
-rw-r--r--discord/audit_logs.py25
-rw-r--r--docs/api.rst8
2 files changed, 19 insertions, 14 deletions
diff --git a/discord/audit_logs.py b/discord/audit_logs.py
index 8ac5722b..b0fef41a 100644
--- a/discord/audit_logs.py
+++ b/discord/audit_logs.py
@@ -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)
+
+ if role is None:
+ role = discord.Object(id=role_id)
+ role.name = e['name']
+
+ data.append(role)
- setattr(second, 'role', role)
+ setattr(second, 'roles', data)
class AuditLogEntry:
"""Represents an Audit Log entry.
diff --git a/docs/api.rst b/docs/api.rst
index ae8ba412..255a20b9 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -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