Table of Contents

Method CreateAutoModerationRuleAsync

Namespace
DSharpPlus.Entities
Assembly
DSharpPlus.dll

CreateAutoModerationRuleAsync(string, DiscordRuleEventType, DiscordRuleTriggerType, DiscordRuleTriggerMetadata, IReadOnlyList<DiscordAutoModerationAction>, Optional<bool>, Optional<IReadOnlyList<DiscordRole>>, Optional<IReadOnlyList<DiscordChannel>>, string?)

Creates an auto-moderation rule in the guild.

public Task<DiscordAutoModerationRule> CreateAutoModerationRuleAsync(string name, DiscordRuleEventType eventType, DiscordRuleTriggerType triggerType, DiscordRuleTriggerMetadata triggerMetadata, IReadOnlyList<DiscordAutoModerationAction> actions, Optional<bool> enabled = default, Optional<IReadOnlyList<DiscordRole>> exemptRoles = default, Optional<IReadOnlyList<DiscordChannel>> exemptChannels = default, string? reason = null)

Parameters

name string

The rule name.

eventType DiscordRuleEventType

The event in which the rule should be triggered.

triggerType DiscordRuleTriggerType

The type of content which can trigger the rule.

triggerMetadata DiscordRuleTriggerMetadata

Metadata used to determine whether a rule should be triggered. This argument can be skipped depending eventType value.

actions IReadOnlyList<DiscordAutoModerationAction>

Actions that will execute after the trigger of the rule.

enabled Optional<bool>

Whether the rule is enabled or not.

exemptRoles Optional<IReadOnlyList<DiscordRole>>

Roles that will not trigger the rule.

exemptChannels Optional<IReadOnlyList<DiscordChannel>>

Channels which will not trigger the rule.

reason string

Reason for audit logs.

Returns

Task<DiscordAutoModerationRule>

The created rule.