@@ -409,8 +409,8 @@ def __init__(self, entry: AuditLogEntry, data: List[AuditLogChangePayload]):
409409
410410 # special case for colors to set secondary and tertiary colos/colour attributes
411411 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
414414 continue
415415
416416 try :
@@ -545,13 +545,18 @@ def _handle_trigger_attr_update(
545545 except (AttributeError , TypeError ):
546546 pass
547547
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
554558
559+ diff .color = diff .colour = colour
555560 diff .secondary_color = diff .secondary_colour = Colour (secondary_colour ) if secondary_colour is not None else None
556561 diff .tertiary_color = diff .tertiary_colour = Colour (tertiary_colour ) if tertiary_colour is not None else None
557562
0 commit comments