Auto Moderation

Auto Moderation, or AutoMod, 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.

AutoMod System Messages

AutoMod system messages are sent as standard messages in the guild with the AUTO_MODERATION_ACTION message type. If no user is associated with the system message, the author is the AutoMod system account (1008776202191634432).

These messages have a special embed structure which contains information about the action that was taken. The custom embed fields below are collapsed as a list of key-value pairs into the fields array on the embed object.

AutoMod Alert

Sent when a SEND_ALERT_MESSAGE action type is triggered.

The author of the message is the user which generated the content that triggered the rule. The embed description contains the user message content that triggered the rule, if applicable.

AutoMod Alert Embed Structure
FieldTypeDescription
rule_namestringThe name of the automod rule that was triggered
decision_idstringThe ID of the decision that was executed
decision_reason?stringThe reason for the decision that was executed
channel_id?snowflakeThe ID of the channel in which the user content was posted
flagged_message_id?snowflakeThe ID of the message that triggered the rule
keywordstringThe word or phrase configured that triggered the rule
keyword_matched_contentstringThe substring in content that triggered the rule
block_profile_update_type?stringThe type of profile update that was blocked
quarantine_user?stringThe reason for quarantining the user
quarantine_user_action?stringThe action taken on the quarantined user
quarantine_event?stringThe user action that triggered the rule
voice_channel_status_outcome?stringThe outcome of the voice channel status update that triggered the rule
timeout_duration?integerDuration (in seconds) after which the timeout expires
alert_actions_execution?alert actions execution objectThe actions that were executed on the AutoMod alert
AutoMod Profile Update Type
ValueDescription
nickname_updateWhen a user updates their nickname in the guild
nickname_resetWhen a user resets their nickname in the guild
AutoMod Quarantine User Reason
ValueDescription
usernameThe user's username triggered the rule
display_nameThe user's display name triggered the rule
bioThe user's bio triggered the rule
nicknameThe user's guild nickname triggered the rule
clan_tagThe user's clan tag triggered the rule
AutoMod Quarantine User Action
ValueDescription
block_guest_joinThe guest was prevented from joining the guild
block_profile_updateThe user was prevented from updating their profile in the guild
quarantine_userThe user was quarantined; quarantined users, similar to timed out users, are prevented from interacting with the guild in any way
AutoMod Quarantine Event Type
ValueDescription
guild_joinWhen a user joins the guild
message_sendWhen a user sends a message in the guild
username_updateWhen a user updates their username
clan_tag_updateWhen a user updates their clan tag
AutoMod Voice Channel Status Outcome
ValueDescription
flaggedThe voice channel status update was flagged by AutoMod
blockedThe voice channel status update was blocked by AutoMod
AutoMod Alert Actions Execution Structure
FieldTypeDescription
vintegerThe alert actions execution protocol version (currently 0)
actionsmap[string, alert action object]The actions that were executed on the AutoMod alert, keyed by action type
AutoMod Alert Action Type
ValueNameDescription
1SET_COMPLETEDMarks the alert as completed
2UNSET_COMPLETEDMarks the alert as not completed
3DELETE_USER_MESSAGEDeletes the user message that triggered the alert
4SUBMIT_FEEDBACKReports an issue with the alert to Discord
AutoMod Alert Action Structure
FieldTypeDescription
actorsnowflakeThe ID of the user that executed the action
tsISO8601 timestampWhen the action was executed
Example AutoMod Alert Embed
{
"type": "auto_moderation_message",
"description": "can i say alien 🥺",
"fields": [
{
"name": "rule_name",
"value": "No aliens",
"inline": false
},
{
"name": "channel_id",
"value": "1121695809839308901",
"inline": false
},
{
"name": "decision_id",
"value": "22a2df4cf7904b81a17faa3e3930af7d",
"inline": false
},
{
"name": "keyword",
"value": "alien",
"inline": false
},
{
"name": "keyword_matched_content",
"value": "alien",
"inline": false
},
{
"name": "flagged_message_id",
"value": "1200705269110411274",
"inline": false
},
{
"name": "timeout_duration",
"value": "600",
"inline": false
},
{
"name": "alert_actions_execution",
"value": "{\"v\": 0, \"actions\": {\"3\": {\"actor\": \"852892297661906993\", \"ts\": \"2024-01-27T07:34:12.145393+00:00\"}, \"1\": {\"actor\": \"852892297661906993\", \"ts\": \"2024-01-27T07:38:29.292345+00:00\"}}}",
"inline": false
}
]
}

AutoMod Incident Notification

Sent when a guild incident activity alert is triggered.

AutoMod Incident Notification Embed Structure
FieldTypeDescription
notification_type?stringThe type of notification that was triggered (default raid)
decision_id?stringThe ID of the decision that was executed
action_by_user_id?snowflakeThe ID of the user that executed the action (only applicable to activity_alerts_enabled notification types)
raid_type?stringThe type of raid that was detected
raid_datetime?ISO8601 timestampWhen the raid was detected
join_attempts?integerThe approximate number of join attempts as part of the raid
dms_sent?integerThe approximate number of sent DMs as part of the raid
suspicious_mention_activity_until?ISO8601 timestampWhen the mention activity restrictions will end (only applicable to mention_raid notification types)
resolved_reason?stringThe reason for resolving the notification
AutoMod Incident Notification Type
ValueDescription
activity_alerts_enabledActivity alerts were enabled in the guild
raidA raid was detected
mention_raidA mention raid was detected
AutoMod Raid Type
ValueDescription
JOIN_RAIDA join raid was detected
MENTION_RAIDA mention raid was detected
AutoMod Raid Resolution Reason
ValueDescription
LEGITIMATE_ACTIVITYThe increased activity was expected
LEGITIMATE_ACCOUNTSThe increased activity was caused by legitimate accounts
LEGITIMATE_DMSThe increased activity was caused by legitimate DMs
DM_SPAMThe increased activity was caused by DM spam and the spammers were removed
JOIN_RAIDThe increased activity was caused by a join raid and the raiders were removed
OTHERThe increased activity was caused by another reason
Example AutoMod Incident Notification Embed
{
"type": "auto_moderation_notification",
"fields": [
{
"name": "notification_type",
"value": "raid",
"inline": false
},
{
"name": "raid_datetime",
"value": "2023-08-15 22:25:33.184657+00:00",
"inline": false
},
{
"name": "raid_type",
"value": "JOIN_RAID",
"inline": false
},
{
"name": "join_attempts",
"value": "25",
"inline": false
},
{
"name": "dms_sent",
"value": "0",
"inline": false
},
{
"name": "resolved_reason",
"value": "LEGITIMATE_ACTIVITY",
"inline": false
}
]
}

AutoMod Rule Object

AutoMod Rule Structure
FieldTypeDescription
idsnowflakeThe ID of the rule
guild_idsnowflakeThe ID of the guild which this rule belongs to
namestringThe name of the rule
creator_idsnowflakeThe ID of the user that created the rule
event_typeintegerThe type of event that triggers the rule
trigger_typeintegerThe type of trigger that invokes the rule
trigger_metadatatrigger metadataMetadata used to determine whether the rule should be triggered
actionsarray[automod action object]The actions that will execute when the rule is triggered
enabledbooleanWhether the rule is enabled
exempt_rolesarray[snowflake]The IDs of the roles that won't be affected by the rule (max 20)
exempt_channelsarray[snowflake]The IDs of the channels that won't be affected by the rule (max 50)
Example AutoMod 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"]
}
AutoMod Trigger Type

Characterizes the type of content which can trigger the rule.

ValueNameDescription
1KEYWORDWhen message content contains words from a user defined list of keywords (max 6)
2HARMFUL_LINKWhen message content contains any harmful links (max 1)
3SPAMWhen message content represents generic spam (max 1)
4KEYWORD_PRESETWhen message content contains words from internal predefined wordsets (max 1)
5MENTION_SPAMWhen message content contains more unique mentions than allowed (max 1)
6USER_PROFILEWhen a user's profile contains words from a user defined list of keywords (max 1)
7GUILD_POLICYWhen a user violates the guild rules (max 1)
AutoMod Trigger Metadata

Additional data used to determine whether a rule should be triggered. Different fields are relevant based on the trigger type.

FieldTypeDescriptionTrigger Type
keyword_filter 1array[string]Substrings which will be searched for in content (1-60 characters, max 1000)KEYWORD, USER_PROFILE
regex_patterns 2array[string]Regular expression patterns which will be matched against content (1-260 characters, max 10)KEYWORD, USER_PROFILE
presetsarray[integer]The internally predefined wordsets which will be searched for in contentKEYWORD_PRESET
allow_list 3array[string]Substrings which should not trigger the rule (1-60 characters, max 100 or 1000 respectively)KEYWORD, KEYWORD_PRESET, USER_PROFILE
mention_total_limitintegerNumber of unique role and user mentions allowed per message (max 50)MENTION_SPAM
mention_raid_protection_enabledbooleanWhether to automatically detect mention raidsMENTION_SPAM

1 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.

2 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.

3 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 types accept a maximum of 100 keywords. Rules with KEYWORD_PRESET trigger types accept a maximum of 1000 keywords.

AutoMod Keyword Preset Type
ValueNameDescription
1PROFANITYWords that may be considered forms of swearing or cursing
2SEXUAL_CONTENTWords that refer to sexually explicit behavior or activity
3SLURSPersonal insults or words that may be considered hate speech
AutoMod Event Type

Indicates in what event context a rule should be checked.

ValueNameDescriptionTrigger Type
1MESSAGE_SENDWhen a member sends or edits a message in the guildKEYWORD, SPAM, KEYWORD_PRESET, MENTION_SPAM, GUILD_POLICY
2GUILD_MEMBER_EVENTWhen a member joins or updates their profileUSER_PROFILE
AutoMod 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

AutoMod Action Object

An action which will execute whenever a rule is triggered.

AutoMod Action Structure
FieldTypeDescription
typeintegerThe type of action
metadata? 1action metadataAdditional metadata needed during execution for this specific action type

1 See the "Action Type" column in action metadata to understand which type values require metadata to be set.

AutoMod Action Type
ValueNameDescription
1BLOCK_MESSAGEBlock a member's message and prevent it from being posted; a custom explanation can be specified and shown to members whenever their message is blocked
2SEND_ALERT_MESSAGE 1Log user content to a specified channel
3TIMEOUT_USER 2Timeout user for a specified duration
4QUARANTINE_USER 3Block guild join, profile update, or quarantine user indefinitely; quarantined users, similar to timed out users, are prevented from interacting with the guild in any way

1 Only a SEND_ALERT_MESSAGE action can be set up for GUILD_POLICY trigger types.

2 A TIMEOUT_USER action can only be set up for KEYWORD and MENTION_SPAM trigger types. The MODERATE_MEMBERS permission is required to use the TIMEOUT_USER action type.

3 A QUARANTINE_USER action can only be set up for USER_PROFILE trigger types. The MODERATE_MEMBERS permission is required to use the QUARANTINE_USER action type.

AutoMod Action Metadata

Additional data used when an action is executed. Different fields are relevant based on the action type.

FieldTypeDescriptionAction Type
channel_idsnowflakeThe channel where user content should be loggedSEND_ALERT_MESSAGE
duration_secondsintegerDuration (in seconds) after which the timeout expires (max 2419200)TIMEOUT_USER
custom_message?stringAdditional explanation that will be shown to members whenever their message is blockedBLOCK_MESSAGE

AutoMod Incidents Data Object

AutoMod Incidents Data Structure
FieldTypeDescription
raid_detected_at?ISO8601 timestampWhen the last raid was detected
dm_spam_detected_at?ISO8601 timestampWhen the last DM spam was detected
invites_disabled_until?ISO8601 timestampWhen invites will be re-enabled (max 24 hours from now)
dms_disabled_until?ISO8601 timestampWhen DMs will be re-enabled (max 24 hours from now)
Example AutoMod Incidents Data
{
"raid_detected_at": "2024-01-01T18:00:00.000000+00:00",
"dm_spam_detected_at": "2024-01-01T18:00:00.000000+00:00",
"invites_disabled_until": "2024-01-01T18:00:00.000000+00:00",
"dms_disabled_until": "2024-01-01T18:00:00.000000+00:00"
}

Endpoints

Get Guild AutoMod Rules

GET/guilds/{guild.id}/auto-moderation/rules

Returns a list of automod rule objects for the configured rules in the guild. Requires the MANAGE_GUILD permission.

Get Guild AutoMod Rule

GET/guilds/{guild.id}/auto-moderation/rules/{automod_rule.id}

Returns an automod rule object for the given rule ID in the guild. Requires the MANAGE_GUILD permission.

Create Guild AutoMod Rule

POST/guilds/{guild.id}/auto-moderation/rules

Creates a new automod rule in the guild. Requires the MANAGE_GUILD permission. Returns an automod rule on success. Fires an Auto Moderation Rule Create Gateway event.

JSON Params
FieldTypeDescription
namestringThe name of the rule
event_typeintegerThe type of event that triggers the rule
trigger_typeintegerThe type of trigger that invokes the rule
trigger_metadata? 1trigger metadataMetadata used to determine whether the rule should be triggered
actionsarray[automod action object]The actions that will execute when the rule is triggered
enabled?booleanWhether the rule is enabled (default false)
exempt_roles?array[snowflake]The IDs of the roles that won't be affected by the rule (max 20)
exempt_channels? 2array[snowflake]The IDs of the channels that won't be affected by the rule (max 50)

1 See the "Trigger Types" column in trigger metadata to understand which trigger types require trigger_metadata to be set.

2 Only applicable to KEYWORD, SPAM, KEYWORD_PRESET, MENTION_SPAM, and GUILD_POLICY trigger types.

Modify Guild AutoMod Rule

PATCH/guilds/{guild.id}/auto-moderation/rules/{automod_rule.id}

Modifies an existing rule in the guild. Requires the MANAGE_GUILD permission. Returns an automod rule on success. Fires an Auto Moderation Rule Update Gateway event.

JSON Params
FieldTypeDescription
name?stringThe name of the rule
event_type?integerThe type of event that triggers the rule
trigger_metadata? 1trigger metadataMetadata used to determine whether the rule should be triggered
actions?array[automod action object]The actions that will execute when the rule is triggered
enabled?booleanWhether the rule is enabled (default false)
exempt_roles?array[snowflake]The IDs of the roles that won't be affected by the rule (max 20)
exempt_channels? 2array[snowflake]The IDs of the channels that won't be affected by the rule (max 50)

1 See the "Trigger Types" column in trigger metadata to understand which trigger types require trigger_metadata to be set.

2 Only applicable to KEYWORD, SPAM, KEYWORD_PRESET, MENTION_SPAM, and GUILD_POLICY trigger types.

Delete Guild AutoMod Rule

DELETE/guilds/{guild.id}/auto-moderation/rules/{automod_rule.id}

Deletes a rule in the guild. Returns a 204 empty response on success. Requires the MANAGE_GUILD permission. Fires an Auto Moderation Rule Delete Gateway event.

Execute AutoMod Alert Action

POST/guilds/{guild.id}/auto-moderation/alert-action

Executes an alert action on an AutoMod alert. Requires the MANAGE_GUILD permission. Returns a 204 empty response on success. Fires a Message Update Gateway event.

JSON Params
FieldTypeDescription
channel_idsnowflakeThe ID of the channel where the alert was sent
message_idsnowflakeThe ID of the AutoMod system message
alert_action_typeintegerThe type of alert action to execute

Modify AutoMod Incident Actions

PUT/guilds/{guild.id}/incident-actions

Sets the incident actions for the guild. Requires the MANAGE_GUILD permission. Fires a Guild Update Gateway event.

JSON Params
FieldTypeDescription
invites_disabled_until?ISO8601 timestampWhen invites will be re-enabled (max 24 hours from now)
dms_disabled_until?ISO8601 timestampWhen DMs will be re-enabled (max 24 hours from now)
Response Body
FieldTypeDescription
invites_disabled_untilISO8601 timestampWhen invites will be re-enabled (max 24 hours from now)
dms_disabled_untilISO8601 timestampWhen DMs will be re-enabled (max 24 hours from now)
Example Response
{
"invites_disabled_until": "2024-01-01T18:00:00.000000+00:00",
"dms_disabled_until": "2024-01-01T18:00:00.000000+00:00"
}

Resolve AutoMod Incident

POST/guilds/{guild.id}/auto-moderation/false-alarm

Resolves an AutoMod incident. Requires the MANAGE_GUILD permission. Returns a 204 empty response on success. Fires a Message Update Gateway event.

JSON Params
FieldTypeDescription
alert_message_idsnowflakeThe ID of the AutoMod system message
reasonstringThe reason for resolving the notification

Report AutoMod Incident

POST/guilds/{guild.id}/auto-moderation/report-raid

Reports an ongoing raid AutoMod incident. Requires the MANAGE_GUILD permission. Returns a 204 empty response on success. Fires a Message Create Gateway event.

Clear Mention Raid Incident

POST/guilds/{guild.id}/auto-moderation/clear-mention-raid

Clears a mention raid AutoMod incident. Requires the MANAGE_GUILD permission. Returns a 204 empty response on success.