pub struct CreateAutoModerationRule<'a> { /* private fields */ }
Expand description

Create an auto moderation rule within a guild.

Requires the MANAGE_GUILD permission.

Examples

Create a rule that deletes messages that contain the word “darn”:

use twilight_http::Client;
use twilight_model::{guild::auto_moderation::AutoModerationEventType, id::Id};

let client = Client::new("my token".to_owned());

let guild_id = Id::new(1);
client
    .create_auto_moderation_rule(guild_id, "no darns", AutoModerationEventType::MessageSend)
    .action_block_message()
    .enabled(true)
    .with_keyword(&["darn"])
    .await?;

Implementations

Append an action of type BlockMessage.

Append an action of type SendAlertMessage.

Append an action of type Timeout.

Set whether the rule is enabled.

Set the channels where the rule does not apply.

Set the roles to which the rule does not apply.

Create the request with the trigger type Keyword, then execute it.

Rules of this type require the keyword_filter field specified, and this method ensures this. See Discord Docs/Keyword Matching Strategies and Discord Docs/Trigger Metadata.

Create the request with the trigger type Spam, then execute it.

Create the request with the trigger type KeywordPreset, then execute it.

Rules of this type require the presets and allow_list fields specified, and this method ensures this. See Discord Docs/Trigger Metadata.

Create the request with the trigger type MentionSpam, then execute it.

Rules of this type requires the mention_total_limit field specified, and this method ensures this. See Discord Docs/Trigger Metadata.

Errors

Returns an error of type AutoModerationMetadataMentionTotalLimit if the limit is invalid.

Trait Implementations

Attach an audit log reason to the request. Read more
Try to convert a request builder into a raw Request. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more