Browse Source

Fix crash from Discord sending null channel_id for automod audit logs

pull/9319/head
Rapptz 2 years ago
parent
commit
ebc1bc3cbb
  1. 10
      discord/audit_logs.py

10
discord/audit_logs.py

@ -521,7 +521,7 @@ class _AuditLogProxyMessageBulkDelete(_AuditLogProxy):
class _AuditLogProxyAutoModAction(_AuditLogProxy):
automod_rule_name: str
automod_rule_trigger_type: str
channel: Union[abc.GuildChannel, Thread]
channel: Optional[Union[abc.GuildChannel, Thread]]
class AuditLogEntry(Hashable):
@ -644,13 +644,17 @@ class AuditLogEntry(Hashable):
or self.action is enums.AuditLogAction.automod_flag_message
or self.action is enums.AuditLogAction.automod_timeout_member
):
channel_id = int(extra['channel_id'])
channel_id = utils._get_as_snowflake(extra, 'channel_id')
channel = None
if channel_id is not None:
channel = self.guild.get_channel_or_thread(channel_id) or Object(id=channel_id)
self.extra = _AuditLogProxyAutoModAction(
automod_rule_name=extra['auto_moderation_rule_name'],
automod_rule_trigger_type=enums.try_enum(
enums.AutoModRuleTriggerType, extra['auto_moderation_rule_trigger_type']
),
channel=self.guild.get_channel_or_thread(channel_id) or Object(id=channel_id),
channel=channel,
)
elif self.action.name.startswith('overwrite_'):

Loading…
Cancel
Save