bot icon indicating copy to clipboard operation
bot copied to clipboard

AttributeError: 'DMChannel' object has no attribute 'mention'

Open sentry-io[bot] opened this issue 2 years ago • 5 comments

Sentry Issue: BOT-3KT

AttributeError: 'DMChannel' object has no attribute 'mention'
  File "bot/exts/filtering/_filter_lists/antispam.py", line 131, in process_deletion_context
    await deletion_context.send_alert(self)
  File "bot/exts/filtering/_filter_lists/antispam.py", line 192, in send_alert
    embed = await build_mod_alert(new_ctx, {antispam_list: messages})
  File "bot/exts/filtering/_ui/ui.py", line 96, in build_mod_alert
    triggered_in += f"**Channels:** {', '.join(channel.mention for channel in ctx.related_channels)}\n"
  File "bot/exts/filtering/_ui/ui.py", line 96, in <genexpr>
    triggered_in += f"**Channels:** {', '.join(channel.mention for channel in ctx.related_channels)}\n"

Error in task Task-131617 140431955642880!

sentry-io[bot] avatar Aug 21 '23 13:08 sentry-io[bot]

Antispam should just ignore the DM channel honestly, that has several issues now that I think about it.

So around this line https://github.com/python-discord/bot/blob/4f4eef6c1701b844a4bb1bc21e6de2b53aa72843/bot/exts/filtering/_filter_lists/antispam.py#L69 we can filter out DM messages.

mbaruh avatar Aug 21 '23 13:08 mbaruh

Antispam should just ignore the DM channel honestly, that has several issues now that I think about it.

Is there a way to filter those messages out of the FilterContext.message_cache before this function even gets hit, or is the caller of this function in a generic super class?

ChrisLovering avatar Aug 21 '23 13:08 ChrisLovering

yeah the cache is used for other stuff so it shouldn't be filtered out there. Not sure what you mean by the caller

mbaruh avatar Aug 21 '23 14:08 mbaruh

Looking back at this I'm not entirely sure what's going on. None of the filters in this list trigger on DMs.

mbaruh avatar Feb 10 '24 09:02 mbaruh

Looks like we already have some code regarding filtering DMs https://github.com/python-discord/bot/blob/577c8da66e618666891eaf237c4e0ca33750230f/bot/exts/filtering/_settings_types/validations/filter_dm.py but it looks like this isn't being used except in a test.

Esther-Goldberg avatar Apr 04 '24 04:04 Esther-Goldberg