From 8bb8b45f0bce5bd2a8b69e5372d6c065e9dbb2bd Mon Sep 17 00:00:00 2001 From: mbaruh Date: Sat, 1 Oct 2022 00:49:00 +0300 Subject: Correctly handle DMs --- bot/exts/filtering/_settings_types/actions/delete_messages.py | 6 ++++-- bot/exts/filtering/_settings_types/validations/channel_scope.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bot/exts/filtering/_settings_types/actions/delete_messages.py b/bot/exts/filtering/_settings_types/actions/delete_messages.py index 710cb0ed8..d1ddf8241 100644 --- a/bot/exts/filtering/_settings_types/actions/delete_messages.py +++ b/bot/exts/filtering/_settings_types/actions/delete_messages.py @@ -22,9 +22,11 @@ class DeleteMessages(ActionEntry): if not self.delete_messages or ctx.event not in (Event.MESSAGE, Event.MESSAGE_EDIT): return + if not ctx.message.guild: + return + with suppress(NotFound): - if ctx.message.guild: - await ctx.message.delete() + await ctx.message.delete() ctx.action_descriptions.append("deleted") def __or__(self, other: ActionEntry): diff --git a/bot/exts/filtering/_settings_types/validations/channel_scope.py b/bot/exts/filtering/_settings_types/validations/channel_scope.py index fd5206b81..be1061199 100644 --- a/bot/exts/filtering/_settings_types/validations/channel_scope.py +++ b/bot/exts/filtering/_settings_types/validations/channel_scope.py @@ -49,6 +49,10 @@ class ChannelScope(ValidationEntry): If the channel is explicitly enabled, it bypasses the set disabled channels and categories. """ channel = ctx.channel + + if channel.guild is None: # This is a DM channel, outside the scope of this setting. + return True + enabled_id = ( channel.id in self.enabled_channels or ( -- cgit v1.2.3