Discord icon

Discord

Interact with Discord API - users, messages, webhooks, guilds, interactions, and more

Actions193

Auto Moderation → Create Rule

AI-generated

Summary

Create an auto-moderation rule for a Discord guild. Choose the event and trigger types, configure trigger metadata and actions, and optionally set exemptions and whether the rule is enabled.

Inputs

  • Guild (required) — The Discord guild ID where the rule will be created.
  • Name (required) — The rule name.
  • Event Type (required) — Choose Message Send or Member Update as the event that triggers the rule.
  • Trigger Type (required) — Choose Keyword, Spam, Keyword Preset, Mention Spam, or Member Profile.
  • Keyword Filter — For Keyword and Member Profile triggers, provide comma-separated substrings to match. Discord supports wildcard syntax such as example; up to 1,000 entries of 60 characters each.
  • Regex Patterns — For Keyword and Member Profile triggers, provide comma-separated Rust regular expressions; up to 10 patterns of 260 characters each.
  • Allow List — Provide comma-separated substrings exempt from the rule. Shown for Keyword, Member Profile, and Keyword Preset triggers; up to 100 entries of 60 characters each.
  • Presets — For Keyword Preset triggers, select Profanity, Sexual Content, or Slurs.
  • Mention Total Limit — For Mention Spam triggers, set the maximum unique user and role mentions allowed per message (1–50).
  • Mention Raid Protection Enabled — For Mention Spam triggers, choose whether automatic mention raid detection is enabled.
  • Trigger Metadata — Raw Discord trigger_metadata JSON escape hatch. Its shape depends on the trigger type; guided fields take precedence when keys overlap.
  • Actions Collection — Add actions to apply when the rule triggers: Block Message (optionally with a custom message), Send Alert Message (requires a channel ID), Timeout (duration in seconds, up to 2,419,200), or Block Member Interaction.
  • Actions — Raw Discord actions JSON array escape hatch. Entries are combined with actions from Actions Collection, with raw entries first.
  • Enabled — Whether the new rule is enabled; defaults to true.
  • Exempt Role IDs — Comma-separated role IDs that the rule should not affect.
  • Exempt Channel IDs — Comma-separated channel IDs that the rule should not affect.
  • Audit Log Reason — Reason recorded in the guild audit log; Discord limits it to 512 characters.
  • Authentication — Choose Bot Token (the default) or OAuth2 user token.

Output shape

A single Discord auto-moderation rule record.

The operation sends a create-rule request for the specified guild. The returned record fields are determined by Discord.

Links

Discussion