mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-08-11 14:02:13 +00:00
Fix key error on role create or delete
This commit is contained in:
parent
7724764ffe
commit
0e97ef21aa
@ -409,8 +409,8 @@ class AuditLogChanges:
|
|||||||
|
|
||||||
# special case for colors to set secondary and tertiary colos/colour attributes
|
# special case for colors to set secondary and tertiary colos/colour attributes
|
||||||
if attr == 'colors':
|
if attr == 'colors':
|
||||||
self._handle_colours(self.before, elem['old_value']) # type: ignore # should be a RoleColours dict
|
self._handle_colours(self.before, elem.get('old_value')) # type: ignore # should be a RoleColours dict
|
||||||
self._handle_colours(self.after, elem['new_value']) # type: ignore # should be a RoleColours dict
|
self._handle_colours(self.after, elem.get('new_value')) # type: ignore # should be a RoleColours dict
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -545,13 +545,18 @@ class AuditLogChanges:
|
|||||||
except (AttributeError, TypeError):
|
except (AttributeError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _handle_colours(self, diff: AuditLogDiff, colours: RoleColours):
|
def _handle_colours(self, diff: AuditLogDiff, colours: Optional[RoleColours]):
|
||||||
# handle colours to multiple colour attributes
|
if colours is not None:
|
||||||
diff.color = diff.colour = Colour(colours['primary_color'])
|
# handle colours to multiple colour attributes
|
||||||
|
colour = Colour(colours['primary_color'])
|
||||||
secondary_colour = colours['secondary_color']
|
secondary_colour = colours['secondary_color']
|
||||||
tertiary_colour = colours['tertiary_color']
|
tertiary_colour = colours['tertiary_color']
|
||||||
|
else:
|
||||||
|
colour = None
|
||||||
|
secondary_colour = None
|
||||||
|
tertiary_colour = None
|
||||||
|
|
||||||
|
diff.color = diff.colour = colour
|
||||||
diff.secondary_color = diff.secondary_colour = Colour(secondary_colour) if secondary_colour is not None else None
|
diff.secondary_color = diff.secondary_colour = Colour(secondary_colour) if secondary_colour is not None else None
|
||||||
diff.tertiary_color = diff.tertiary_colour = Colour(tertiary_colour) if tertiary_colour is not None else None
|
diff.tertiary_color = diff.tertiary_colour = Colour(tertiary_colour) if tertiary_colour is not None else None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user