automod_create_rule
automod_create_rule
Section titled “automod_create_rule”Category: automod
Create an AutoMod rule.
When to use
Section titled “When to use”- Add a keyword filter, spam blocker, mention-raid guard, etc.
trigger_metadata is conditional on trigger_type:
- 1 KEYWORD → keyword_filter, regex_patterns, allow_list
- 3 SPAM → no metadata
- 4 KEYWORD_PRESET → presets, allow_list
- 5 MENTION_SPAM → mention_total_limit, mention_raid_protection_enabled
- 6 MEMBER_PROFILE → keyword_filter, regex_patterns, allow_list
When NOT to use
Section titled “When NOT to use”| Field | Type | Required | Description |
|---|---|---|---|
guild_id | string | yes | Target guild |
name | string | yes | Rule name |
event_type | integer | yes | AutoMod event type (1 MESSAGE_SEND, 2 MEMBER_UPDATE) |
trigger_type | integer | yes | AutoMod trigger type (1 KEYWORD, 3 SPAM, 4 KEYWORD_PRESET, 5 MENTION_SPAM, 6 MEMBER_PROFILE) |
trigger_metadata | object | no | AutoMod trigger metadata (fields valid per trigger_type) |
actions | array | yes | Actions to take when the rule fires |
enabled | boolean | no | Whether the rule is active (default true) |
exempt_roles | array | no | Roles exempt from this rule (max 20) |
exempt_channels | array | no | Channels exempt from this rule (max 50) |
audit_reason | string | no | Reason recorded in audit log (X-Audit-Log-Reason header) |
Returns
Section titled “Returns”\{id, name, trigger_type, enabled\}.
Output schema
Section titled “Output schema”| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Discord AutoMod rule ID |
name | string | yes | |
trigger_type | integer | yes | |
enabled | boolean | yes |
Annotations
Section titled “Annotations”| Property | Value |
|---|---|
| Read-only | no |
| Destructive | no |
| Idempotent | no |
| Open-world | yes |
| Confirmation required | no |