Custom AutoMod Actions #6009
Replies: 2 comments 14 replies
-
If you look in the DDev docs they allow you to create an auto mod rule |
Beta Was this translation helpful? Give feedback.
-
Bringing this up again in 2025 because it's more relevant than ever. AutoMod rules are a great tool for intercepting and moderating messages before they’re sent in the chat. However, there are significant gaps in how they function, or at least how they’re documented. For example, the execution order of rules is unclear, and it’s not fully explained how "allowlists" interact with wildcards (wildcards seem to consume characters, which can create vulnerabilities). There’s also no built-in "anti-link" rule to allow specific domains while blocking others. This makes it difficult to block all links except for a few safe ones. Worse, wildcards can be exploited to bypass such rules, e.g., using One potential improvement would be to allow custom AutoMod actions, enabling bots to handle more complex scenarios. Here’s an idea for how this could work: an "event" could be triggered to the bot’s WebSocket connection, allowing the bot to process the message and decide the appropriate action. While this approach could add latency and strain the API, a workaround might involve sending the full message payload to the bot with a signature valid for up to 3 seconds (similar to the default interaction response timeout). The bot could then respond with the same payload and signature to either approve or block the message. This would eliminate the need for the Discord API to track user messages, as the signature would confirm the message originated from a specific user (e.g., user ID "X"). If approved, the bot could resend the message on behalf of the user. Additionally, custom AutoMod rules could include a fallback action if the bot doesn’t respond in time (e.g., block the message, issue a timeout, etc.). This functionality could be extended to other events, such as bans, kicks, or timeouts, enabling bots to mitigate mass bans or enforce limits on such actions in real-time. |
Beta Was this translation helpful? Give feedback.
-
With the built-in AutoMod, it allows servers to filter out or flag messages before they're sent. This works great, and it can also work with bots, by having bots listen to the Auto Moderation Action Execution event. This currently allows bots to detect when a rule has been triggered and take action accordingly, but (as far as I've seen) hasn't gotten much use.
The current situation
With the current 3 built-in actions (alert, delete, and timeout), a lot of simple moderation can happen automatically, but you can't achieve more complex things like tracking multiple triggers of the rule, following a tiered system of actions, etc.
Bots can currently listen to the trigger events for automod rules to provide this extended functionality, but the UX for assigning them isn't great. The ways currently possible are:
The other problem is this requires running a bot connected to the gateway in order to listen to these events, so HTTP-only bots can't take advantage of the features AutoMod provides.
Proposed solution
Allow bots to add custom AutoMod actions. These would be registered with Discord ahead of time similar to role connection metadata or slash commands, where the bot can provide a set number of available action types as well as what parameters they take.
For instance, let's say my bot provides a system where if a user triggers an automod rule X times within Y minutes, they will be timed out for Z minutes. I could register a custom action named "Throttled Timeout" (or similar, should also support i18n like slash commands), and the custom action would have 3 options, all numbers, named "Number of Triggers", "Time Limit", and "Timeout Length". Now that I've registered this custom action, any server that has my bot will see this in the list of available actions when configuring AutoMod rules. They can select the action and configure their parameters to add this action to the rule.
Now that it's configured, any time that AutoMod rule is triggered, my bot can listen for the Auto Moderation Action Execution and check if it matches my custom action. If it does, it can read the parameters and take action on the user.
This could also potentially trigger an interaction to be sent to bots that use them and allow HTTP-only bots to receive these events like that instead of over the gateway.
Beta Was this translation helpful? Give feedback.
All reactions