diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 59d563829257..af67855d4584 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -874,7 +874,13 @@ def _convert_target_invite(self, target_id: None) -> Invite: def _convert_target_emoji(self, target_id: int) -> Union[Emoji, Object]: return self._state.get_emoji(target_id) or Object(id=target_id, type=Emoji) - def _convert_target_message(self, target_id: int) -> Union[Member, User, Object]: + def _convert_target_message(self, target_id: Optional[int]) -> Optional[Union[Member, User, Object]]: + # The message_pin and message_unpin action types do not have a + # non-null target_id so safeguard against that + + if target_id is None: + return None + return self._get_member(target_id) or Object(id=target_id, type=Member) def _convert_target_stage_instance(self, target_id: int) -> Union[StageInstance, Object]: