# Create AutoMod Rule

> Create an auto moderation rule.

- ID: `create_automod_rule`
- Type: Block
- Category: [Auto Moderation](https://inventor.bot/docs/reference/blocks/auto-moderation.md)

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `server_id` | yes | Server to create the rule in. |  |
| `name` | yes | Name of the rule. |  |
| `event_type` |  | Event context for the rule. | `"Message Send"`, `"Member Update"` |
| `trigger_type` | yes | Type of content that triggers the rule. | `"Keyword"`, `"Spam"`, `"Keyword Preset"`, `"Mention Spam"`, `"Member Profile"` |
| `keyword_filter` |  | Comma-separated keywords to match against. |  |
| `regex_patterns` |  | Comma-separated regex patterns to match against. |  |
| `presets` |  | Pre-defined wordsets to use. | `"Profanity"`, `"Sexual Content"`, `"Slurs"` |
| `allow_list` |  | Comma-separated words that should not trigger the rule. |  |
| `mention_total_limit` |  | Max unique role and user mentions allowed per message. |  |
| `enabled` |  | Whether the rule is enabled. | `"true"`, `"false"` |
| `exempt_roles` |  | Comma-separated role IDs exempt from the rule. |  |
| `exempt_channels` |  | Comma-separated channel IDs exempt from the rule. |  |
| `action_type` | yes | Action to take when the rule is triggered. | `"Block Message"`, `"Send Alert Message"`, `"Timeout"` |
| `action_channel_id` |  | Channel for alert messages (used with Send Alert Message). |  |
| `action_duration_seconds` |  | Timeout duration in seconds (used with Timeout). |  |
| `action_custom_message` |  | Custom message shown when a message is blocked (used with Block Message). |  |

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `rule_id` | ID of the created rule. |  |
| `server_id` | ID of the server. |  |
| `name` | Name of the rule. |  |
| `creator_id` | User who created the rule. |  |
| `enabled` | Whether the rule is enabled. |  |
| `event_type` | Event type. |  |
| `trigger_type` | Trigger type. |  |

**Example**

```go
automodRule := create_automod_rule(Args{
	server_id:    trigger.server_id,
	name:         "...",
	trigger_type: "Keyword",
	action_type:  "Block Message",
})
send_text_message(Args{
	channel_id:      trigger.channel_id,
	message_content: "Rule ID: " + automodRule.rule_id,
})
```