Skip to content

AutomoderationRuleBuilder

AutomoderationRuleBuilder is used to construct an auto-moderation rule for a Discord guild, including trigger types, actions, and exempt roles or channels.

Usage:

local rule = AutomoderationRuleBuilder.new()
:setName("No Profanity")
:setEventType(AutomoderationRuleBuilder.EventType.MessageSend)
:setTriggerType(AutomoderationRuleBuilder.TriggerType.Keyword)
:setTriggerMetadata({ keywordFilter = {"badword1", "badword2"} })
:addAction(AutomoderationRuleBuilder.ActionType.BlockMessage, { customMessage = "Profanity is not allowed!" })
:setEnabled(true)

Properties

EventType

AutomoderationRuleBuilder.EventType  :: table

An enumeration of event types.

  • MessageSend: 1

TriggerType

AutomoderationRuleBuilder.TriggerType  :: table

An enumeration of trigger types.

  • Keyword: 1
  • Spam: 3
  • KeywordPreset: 4
  • MentionSpam: 5

KeywordPresets

AutomoderationRuleBuilder.KeywordPresets  :: table

An enumeration of keyword presets.

  • Profanity: 1
  • SexualContent: 2
  • Slurs: 3

ActionType

AutomoderationRuleBuilder.ActionType  :: table

An enumeration of action types.

  • BlockMessage: 1
  • SendAlertMessage: 2
  • Timeout: 3

Methods

setName

AutomoderationRuleBuilder : setName (

     name: string
)  -> Builders.AutomoderationRuleBuilder

Sets the name of the rule.

setEventType

AutomoderationRuleBuilder : setEventType (

     eventType: number
)  -> Builders.AutomoderationRuleBuilder

Sets the event type for the rule.

setTriggerType

AutomoderationRuleBuilder : setTriggerType (

     triggerType: number
)  -> Builders.AutomoderationRuleBuilder

Sets the trigger type for the rule.

setTriggerMetadata

AutomoderationRuleBuilder : setTriggerMetadata (

     triggerMetadata: table
)  -> Builders.AutomoderationRuleBuilder

Sets the trigger metadata for the rule.

addAction

AutomoderationRuleBuilder : addAction (

     actionType: number
     actionMetadata: table
)  -> Builders.AutomoderationRuleBuilder

Adds an action to the rule.

setEnabled

AutomoderationRuleBuilder : setEnabled (

     enabled: boolean
)  -> Builders.AutomoderationRuleBuilder

Sets whether the rule is enabled.

addExemptRole

AutomoderationRuleBuilder : addExemptRole (

     roleId: string
)  -> Builders.AutomoderationRuleBuilder

Adds an exempt role to the rule.

addExemptChannel

AutomoderationRuleBuilder : addExemptChannel (

     channelId: string
)  -> Builders.AutomoderationRuleBuilder

Adds an exempt channel to the rule.

toPayloadObject

AutomoderationRuleBuilder : toPayloadObject ()  -> Network.Resolvable

Converts the rule to a JSON object that can be sent to the Discord API.

Functions

new

AutomoderationRuleBuilder . new ()  -> ()

Creates a new instance of AutomoderationRuleBuilder.