python-discord / bot

The community bot for the Python Discord community
https://pythondiscord.com
MIT License
1.34k stars 666 forks source link

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

Open sentry-io[bot] opened 1 year ago

sentry-io[bot] commented 1 year ago

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!
mbaruh commented 1 year ago

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.

ChrisLovering commented 1 year ago

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?

mbaruh commented 1 year ago

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 commented 7 months ago

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

Esther-Goldberg commented 5 months ago

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.