Skip to content

Message Filters Should Not Attempt to Delete Messages in DMs #933

@sentry

Description

@sentry

Filters that attempt to delete offending message(s) should check whether or not the message was sent in a DM, since the bot cannot delete others' DM messages.

Forbidden: 403 Forbidden (error code: 50003): Cannot execute action on a DM channel
  File "discord/client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "bot/cogs/filtering.py", line 114, in on_message
    await self._filter_message(msg)
  File "bot/cogs/filtering.py", line 176, in _filter_message
    await msg.delete()
  File "discord/message.py", line 762, in delete
    await self._state.http.delete_message(self.channel.id, self.id)
  File "discord/http.py", line 221, in request
    raise Forbidden(r, data)

Unhandled exception in on_message.

Sentry Issue: BOT-3W

Metadata

Metadata

Assignees

Labels

a: filtersRelated to message filters: (antimalware, antispam, filtering, token_remover)p: 2 - normalNormal Prioritys: WIPWork In Progresst: bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions