> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Create Auto Moderation rule

> Create a Discord Auto Moderation rule.

`discord.createAutomodRule` creates a Discord Auto Moderation rule.

```ts automations/discord-create-automod-rule.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { discord } from "automate.ax/discord"

export default automation("Create Auto Moderation rule", () => {
  onHttpRequest({ scope: "automation" })
  discord.createAutomodRule({
    guildId: "123456789012345678",
    name: "Block spam",
    triggerType: "keyword",
    keywordFilter: ["spam"],
    actions: [{ type: "blockMessage" }],
    enabled: true,
  })
})
```

## Inputs

Required `guildId`, `name`, `triggerType`, and one to three actions. Matching fields support keywords, regex, presets, mention limits, and allow lists; optional exemptions and audit-log `reason`. Optional second argument `{ account }` selects the Discord binding.

## Output

Returns the created `DiscordAutomodRule`.

## Discord behavior

Requires `MANAGE_GUILD`. Action types must be unique. Mention-spam rules require `mentionTotalLimit`; keyword-preset rules require at least one entry in `presets`. `sendAlert` actions require `channelId`, `timeoutMember` actions require `durationSeconds`, and `blockMessage` actions accept optional `customMessage`. Keyword and mention-spam rules support block, alert, and timeout actions. Spam and preset rules support block and alert actions. Member-profile rules support alert and block-interaction actions. Timeout also requires `MODERATE_MEMBERS`. `eventType` defaults to `memberUpdate` for `memberProfile` triggers and `messageSend` otherwise. Explicit event and trigger types must be compatible.
