Skip to main content
Auto Moderation is a feature which allows each guild to set up rules that trigger based on some criteria. For example, a rule can trigger whenever a message contains a specific keyword. Rules can be configured to automatically execute actions whenever they trigger. For example, if a user tries to send a message which contains a certain keyword, a rule can trigger and block the message before it is sent.

Auto Moderation Rule Object

Auto Moderation Rule Structure
FieldTypeDescription
idsnowflakethe id of this rule
guild_idsnowflakethe id of the guild which this rule belongs to
namestringthe rule name
creator_idsnowflakethe user which first created this rule
event_typeintegerthe rule event type
trigger_typeintegerthe rule trigger type
trigger_metadataobjectthe rule trigger metadata
actionsarray of action objectsthe actions which will execute when the rule is triggered
enabledbooleanwhether the rule is enabled
exempt_rolesarray of snowflakesthe role ids that should not be affected by the rule (Maximum of 20)
exempt_channelsarray of snowflakesthe channel ids that should not be affected by the rule (Maximum of 50)
Example Auto Moderation Rule
{
  "id": "969707018069872670",
  "guild_id": "613425648685547541",
  "name": "Keyword Filter 1",
  "creator_id": "423457898095789043",
  "trigger_type": 1,
  "event_type": 1,
  "actions": [
    {
      "type": 1,
      "metadata": { "custom_message": "Please keep financial discussions limited to the #finance channel" }
    },
    {
      "type": 2,
      "metadata": { "channel_id": "123456789123456789" }
    },
    {
      "type": 3,
      "metadata": { "duration_seconds": 60 }
    }
  ],
  "trigger_metadata": {
    "keyword_filter": ["cat*", "*dog", "*ana*", "i like c++"],
    "regex_patterns": ["(b|c)at", "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$"]
  },
  "enabled": true,
  "exempt_roles": ["323456789123456789", "423456789123456789"],
  "exempt_channels": ["523456789123456789"]
}
Trigger Types
Characterizes the type of content which can trigger the rule.
Trigger TypeValueDescriptionMax per Guild
KEYWORD1check if content contains words from a user defined list of keywords6
SPAM3check if content represents generic spam1
KEYWORD_PRESET4check if content contains words from internal pre-defined wordsets1
MENTION_SPAM5check if content contains more unique mentions than allowed1
MEMBER_PROFILE6check if member profile contains words from a user defined list of keywords1
Trigger Metadata
Additional data used to determine whether a rule should be triggered. Different fields are relevant based on the value of trigger_type.
FieldTypeAssociated Trigger TypesDescription
keyword_filterarray of strings *KEYWORD, MEMBER_PROFILEsubstrings which will be searched for in content (Maximum of 1000)
regex_patternsarray of strings **KEYWORD, MEMBER_PROFILEregular expression patterns which will be matched against content (Maximum of 10)
presetsarray of keyword preset typesKEYWORD_PRESETthe internally pre-defined wordsets which will be searched for in content
allow_listarray of strings ***KEYWORD, KEYWORD_PRESET, MEMBER_PROFILEsubstrings which should not trigger the rule (Maximum of 100 or 1000)
mention_total_limitintegerMENTION_SPAMtotal number of unique role and user mentions allowed per message (Maximum of 50)
mention_raid_protection_enabledbooleanMENTION_SPAMwhether to automatically detect mention raids
* A keyword can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less. ** Only Rust flavored regex is currently supported, which can be tested in online editors such as Rustexp. Each regex pattern must be 260 characters or less. *** Each allow_list keyword can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each keyword will be matched. Rules with KEYWORD trigger_type accept a maximum of 100 keywords. Rules with KEYWORD_PRESET trigger_type accept a maximum of 1000 keywords.
Trigger Metadata Field Limits
FieldTrigger TypesMAX ARRAY LENGTHMAX CHARACTERS PER STRING
keyword_filterKEYWORD, MEMBER_PROFILE100060
regex_patternsKEYWORD, MEMBER_PROFILE10260
allow_listKEYWORD, MEMBER_PROFILE10060
allow_listKEYWORD_PRESET100060
Keyword Preset Types
Preset TypeValueDescription
PROFANITY1words that may be considered forms of swearing or cursing
SEXUAL_CONTENT2words that refer to sexually explicit behavior or activity
SLURS3personal insults or words that may be considered hate speech
Event Types
Indicates in what event context a rule should be checked.
Event TypeValueDescription
MESSAGE_SEND1when a member sends or edits a message in the guild
MEMBER_UPDATE2when a member edits their profile
Keyword Matching Strategies
Use the wildcard symbol (*) at the beginning or end of a keyword to define how it should be matched. All keywords are case insensitive. Prefix - word must start with the keyword
KeywordMatches
cat*catch, Catapult, CAttLE
tra*train, trade, TRAditional
the mat*the matrix
Suffix - word must end with the keyword
KeywordMatches
*catwildcat, copyCat
*traextra, ultra, orchesTRA
*the matbreathe mat
Anywhere - keyword can appear anywhere in the content
KeywordMatches
*cat*location, eduCation
*tra*abstracted, outrage
*the mat*breathe matter
Whole Word - keyword is a full word or phrase and must be surrounded by whitespace
KeywordMatches
catcat
traintrain
the matthe mat

Auto Moderation Action Object

An action which will execute whenever a rule is triggered.
Auto Moderation Action Structure
FieldTypeDescription
typeaction typethe type of action
metadata? *action metadataadditional metadata needed during execution for this specific action type
* Can be omitted based on type. See the Associated Action Types column in action metadata to understand which type values require metadata to be set.
Action Types
Action TypeValueDescription
BLOCK_MESSAGE1blocks a member’s message and prevents it from being posted. A custom explanation can be specified and shown to members whenever their message is blocked.
SEND_ALERT_MESSAGE2logs user content to a specified channel
TIMEOUT3timeout user for a specified duration *
BLOCK_MEMBER_INTERACTION4prevents a member from using text, voice, or other interactions
* A TIMEOUT action can only be set up for KEYWORD and MENTION_SPAM rules. The MODERATE_MEMBERS permission is required to use the TIMEOUT action type.
Action Metadata
Additional data used when an action is executed. Different fields are relevant based on the value of action type.
FieldTypeAssociated Action TypesDescriptionConstraints
channel_idsnowflakeSEND_ALERT_MESSAGEchannel to which user content should be loggedexisting channel
duration_secondsintegerTIMEOUTtimeout duration in secondsmaximum of 2419200 seconds (4 weeks)
custom_message?stringBLOCK_MESSAGEadditional explanation that will be shown to members whenever their message is blockedmaximum of 150 characters

Auto Moderation Permission Requirements

Users are required to have the MANAGE_GUILD permission to access all Auto Moderation resources. Some action types require additional permissions, e.g. the TIMEOUT action type requires an additional MODERATE_MEMBERS permission.

List Auto Moderation Rules for Guild

GET/guilds/{guild.id}/auto-moderation/rules
Get a list of all rules currently configured for the guild. Returns a list of auto moderation rule objects for the given guild.
This endpoint requires the MANAGE_GUILD permission.

Get Auto Moderation Rule

GET/guilds/{guild.id}/auto-moderation/rules/{auto_moderation_rule.id}
Get a single rule. Returns an auto moderation rule object.
This endpoint requires the MANAGE_GUILD permission.

Create Auto Moderation Rule

POST/guilds/{guild.id}/auto-moderation/rules
Create a new rule. Returns an auto moderation rule on success. Fires an Auto Moderation Rule Create Gateway event.
This endpoint requires the MANAGE_GUILD permission.
This endpoint supports the X-Audit-Log-Reason header.
JSON Params
FieldTypeDescription
namestringthe rule name
event_typeintegerthe event type
trigger_typeintegerthe trigger type
trigger_metadata? *objectthe trigger metadata
actionsarray of action objectsthe actions which will execute when the rule is triggered
enabled?booleanwhether the rule is enabled (False by default)
exempt_roles?array of snowflakesthe role ids that should not be affected by the rule (Maximum of 20)
* Can be omitted based on trigger_type. See the Associated Trigger Types column in trigger metadata to understand which trigger_type values require trigger_metadata to be set.
See Trigger Types for limits on how many rules of each trigger type can be created per guild.

Modify Auto Moderation Rule

PATCH/guilds/{guild.id}/auto-moderation/rules/{auto_moderation_rule.id}
Modify an existing rule. Returns an auto moderation rule on success. Fires an Auto Moderation Rule Update Gateway event.
Requires MANAGE_GUILD permissions.
All parameters for this endpoint are optional.
This endpoint supports the X-Audit-Log-Reason header.
JSON Params
FieldTypeDescription
namestringthe rule name
event_typeintegerthe event type
trigger_metadata? *objectthe trigger metadata
actionsarray of action objectsthe actions which will execute when the rule is triggered
enabledbooleanwhether the rule is enabled
exempt_rolesarray of snowflakesthe role ids that should not be affected by the rule (Maximum of 20)
exempt_channelsarray of snowflakesthe channel ids that should not be affected by the rule (Maximum of 50)
* Can be omitted based on trigger_type. See the Associated Trigger Types column in trigger metadata to understand which trigger_type values require trigger_metadata to be set.

Delete Auto Moderation Rule

DELETE/guilds/{guild.id}/auto-moderation/rules/{auto_moderation_rule.id}
Delete a rule. Returns a 204 on success. Fires an Auto Moderation Rule Delete Gateway event.
This endpoint requires the MANAGE_GUILD permission.
This endpoint supports the X-Audit-Log-Reason header.