Browse Source

Fix audit logs for INVITE_CREATE returning None

pull/7750/head
Alex Nørgaard 3 years ago
committed by GitHub
parent
commit
7a815a97af
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      discord/audit_logs.py

6
discord/audit_logs.py

@ -483,12 +483,14 @@ class AuditLogEntry(Hashable):
@utils.cached_property
def target(self) -> TargetType:
if self._target_id is None or self.action.target_type is None:
if self.action.target_type is None:
return None
try:
converter = getattr(self, '_convert_target_' + self.action.target_type)
except AttributeError:
if self._target_id is None:
return None
return Object(id=self._target_id)
else:
return converter(self._target_id)
@ -527,7 +529,7 @@ class AuditLogEntry(Hashable):
def _convert_target_role(self, target_id: int) -> Union[Role, Object]:
return self.guild.get_role(target_id) or Object(id=target_id)
def _convert_target_invite(self, target_id: int) -> Invite:
def _convert_target_invite(self, target_id: None) -> Invite:
# invites have target_id set to null
# so figure out which change has the full invite data
changeset = self.before if self.action is enums.AuditLogAction.invite_delete else self.after

Loading…
Cancel
Save