Existing offensive messages sometimes posted again
Sentry Issue: [BOT-6B](https://sentry.io/organizations/python-discord/issues/1732235421/?referrer=github_integration)

My guess is this happens when an edited message re-triggers a filter. If this is indeed the case, then the error can simply be ignored.

```
ResponseCodeError: Status: 400 Response: {'id': ['offensive message with this id already exists.']}
(1 additional frame(s) were not displayed)
...
  File "bot/cogs/filtering.py", line 143, in on_message_edit
    await self._filter_message(after, delta)
  File "bot/cogs/filtering.py", line 304, in _filter_message
    await self.bot.api_client.post('bot/offensive-messages', json=data)
  File "bot/api.py", line 127, in post
    return await self.request("POST", endpoint, raise_for_status=raise_for_status, **kwargs)
  File "bot/api.py", line 114, in request
    await self.maybe_raise_for_status(resp, raise_for_status)
  File "bot/api.py", line 104, in maybe_raise_for_status
    raise ResponseCodeError(response=response, response_json=response_json)

Unhandled exception in on_message_edit.
```
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py
index 93cc1c65..99b659bf 100644
--- a/bot/cogs/filtering.py
+++ b/bot/cogs/filtering.py
@@ -11,6 +11,7 @@ from discord import Colour, HTTPException, Member, Message, NotFound, TextChanne
 from discord.ext.commands import Cog
 from discord.utils import escape_markdown
 
+from bot.api import ResponseCodeError
 from bot.bot import Bot
 from bot.cogs.moderation import ModLog
 from bot.constants import (
@@ -301,9 +302,16 @@ class Filtering(Cog):
                                 'delete_date': delete_date
                             }
 
-                            await self.bot.api_client.post('bot/offensive-messages', json=data)
-                            self.schedule_msg_delete(data)
-                            log.trace(f"Offensive message {msg.id} will be deleted on {delete_date}")
+                            try:
+                                await self.bot.api_client.post('bot/offensive-messages', json=data)
+                            except ResponseCodeError as e:
+                                if e.status == 400 and "already exists" in e.response_json.get("id", [""])[0]:
+                                    log.debug(f"Offensive message {msg.id} already exists.")
+                                else:
+                                    log.error(f"Offensive message {msg.id} failed to post: {e}")
+                            else:
+                                self.schedule_msg_delete(data)
+                                log.trace(f"Offensive message {msg.id} will be deleted on {delete_date}")
 
                         if is_private:
                             channel_str = "via DM"
['bot/cogs/filtering.py']