Skip to content

Rule

Implementation of a discord automoderation rule object as a luau builder.

https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object

Rule.name  :: string

The name of the automoderation rule.

Rule.eventType  :: EventTypes

The event type that will trigger the rule.

Rule.triggerType  :: TriggerTypes

The type of content which can trigger the rule.

Rule.triggerMetadata  :: TriggerMetadata

The trigger metadata for the rule.

Rule.actions  :: Action}

The actions which will execute when the rule is triggered.

Rule.enabled  :: boolean

Whether the rule is enabled.

Rule.exemptRoles  :: {string}

The role ids that should not be affected by the rule.

Rule.exemptChannels  :: {string}

The channel ids that should not be affected by the rule.

Rule : setName ( name )  -> AutomoderationRule

Sets the name of the automoderation rule.

Parameters

name: string

Returns

AutomoderationRule
Rule : setEventType ( eventType )  -> AutomoderationRule

Sets the event type for the automoderation rule.

Parameters

eventType: EventTypes

Returns

AutomoderationRule
Rule : setTriggerType ( triggerType )  -> AutomoderationRule

Sets the trigger type for the automoderation rule.

Parameters

triggerType: TriggerTypes

Returns

AutomoderationRule
Rule : setTriggerMetadata ( triggerMetadata )  -> AutomoderationRule

Sets the trigger metadata for the automoderation rule.

Parameters

triggerMetadata: JSON

Returns

AutomoderationRule
Rule : setActions ( actions )  -> AutomoderationRule

Sets the actions for the automoderation rule.

Parameters

actions: JSON }

Returns

AutomoderationRule
Rule : setEnabled ( enabled )  -> AutomoderationRule

Sets whether the automoderation rule is enabled.

Parameters

enabled: boolean

Returns

AutomoderationRule
Rule : setExemptRoles ( exemptRoles )  -> AutomoderationRule

Sets the exempt roles for the automoderation rule.

Parameters

exemptRoles: Snowflake }

Returns

AutomoderationRule
Rule : setExemptChannels ( exemptChannels )  -> AutomoderationRule

Sets the exempt channels for the automoderation rule.

Parameters

exemptChannels: Snowflake }

Returns

AutomoderationRule
Rule : build ( )  -> JSON

Builds the automoderation rule object.

Returns

JSON
Rule . new ( resource )  -> AutomoderationRule

Constructs a new automoderation rule builder.

local rule = AutomoderationRule.new({
name = "My Rule",
eventType = "MESSAGE_SEND",
triggerType = "KEYWORD",
actions = {
{
type = "BLOCK_MESSAGE",
metadata = {}
}
}
})

Parameters

resource: {
name: string?,
eventType: apiTypes.EventTypes?,
triggerType: apiTypes.TriggerTypes?,
triggerMetadata: triggerMetadata.JSON?,
actions: { action.JSON,
}

Returns

AutomoderationRule