@@ -409,8 +409,8 @@ def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]):
409
409
410
410
# special case for colors to set secondary and tertiary colos/colour attributes
411
411
if attr == 'colors' :
412
- self ._handle_colours (self .before , elem [ 'old_value' ] ) # type: ignore # should be a RoleColours dict
413
- self ._handle_colours (self .after , elem [ 'new_value' ] ) # type: ignore # should be a RoleColours dict
412
+ self ._handle_colours (self .before , elem . get ( 'old_value' ) ) # type: ignore # should be a RoleColours dict
413
+ self ._handle_colours (self .after , elem . get ( 'new_value' ) ) # type: ignore # should be a RoleColours dict
414
414
continue
415
415
416
416
try :
@@ -545,13 +545,18 @@ def _handle_trigger_attr_update(
545
545
except (AttributeError , TypeError ):
546
546
pass
547
547
548
- def _handle_colours (self , diff : AuditLogDiff , colours : RoleColours ):
549
- # handle colours to multiple colour attributes
550
- diff .color = diff .colour = Colour (colours ['primary_color' ])
551
-
552
- secondary_colour = colours ['secondary_color' ]
553
- tertiary_colour = colours ['tertiary_color' ]
548
+ def _handle_colours (self , diff : AuditLogDiff , colours : Optional [RoleColours ]):
549
+ if colours is not None :
550
+ # handle colours to multiple colour attributes
551
+ colour = Colour (colours ['primary_color' ])
552
+ secondary_colour = colours ['secondary_color' ]
553
+ tertiary_colour = colours ['tertiary_color' ]
554
+ else :
555
+ colour = None
556
+ secondary_colour = None
557
+ tertiary_colour = None
554
558
559
+ diff .color = diff .colour = colour
555
560
diff .secondary_color = diff .secondary_colour = Colour (secondary_colour ) if secondary_colour is not None else None
556
561
diff .tertiary_color = diff .tertiary_colour = Colour (tertiary_colour ) if tertiary_colour is not None else None
557
562
0 commit comments