#[non_exhaustive]pub struct Action {
pub kind: ActionType,
pub metadata: Option<ActionMetadata>,
}Expand description
An action taken when a rule triggers.
discord.js counterpart: AutoModerationAction.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: ActionTypeWhat the action does.
metadata: Option<ActionMetadata>Settings of the action; required for SendAlertMessage and Timeout.
Implementations§
Source§impl Action
Constructors for each ActionType, setting the metadata it requires (D-129).
impl Action
Constructors for each ActionType, setting the metadata it requires (D-129).
§Examples
use djs_model::{auto_moderation::Action, id::ChannelId};
let actions = [
Action::block_message_with("Please keep it friendly"),
Action::send_alert_message(ChannelId::new(1)),
Action::timeout(60 * 10),
];
assert_eq!(
serde_json::to_string(&actions)?,
r#"[{"type":1,"metadata":{"custom_message":"Please keep it friendly"}},{"type":2,"metadata":{"channel_id":"1"}},{"type":3,"metadata":{"duration_seconds":600}}]"#
);Sourcepub const fn block_message() -> Self
pub const fn block_message() -> Self
Blocks the message with Discord’s default explanation.
discord.js counterpart: an AutoModerationActionOptions of type AutoModerationActionType.BlockMessage.
Sourcepub fn block_message_with(custom_message: impl Into<CompactString>) -> Self
pub fn block_message_with(custom_message: impl Into<CompactString>) -> Self
Blocks the message and shows custom_message (up to 150 characters) to the member.
discord.js counterpart: an AutoModerationActionOptions of type AutoModerationActionType.BlockMessage, with customMessage.
Sourcepub const fn send_alert_message(channel_id: ChannelId) -> Self
pub const fn send_alert_message(channel_id: ChannelId) -> Self
Logs the content to channel_id.
discord.js counterpart: an AutoModerationActionOptions of type AutoModerationActionType.SendAlertMessage.
Sourcepub const fn timeout(duration_seconds: u32) -> Self
pub const fn timeout(duration_seconds: u32) -> Self
Times the member out for duration_seconds (up to 2 419 200, four weeks). Only for
Keyword and MentionSpam rules; needs the MODERATE_MEMBERS permission.
discord.js counterpart: an AutoModerationActionOptions of type AutoModerationActionType.Timeout.
Sourcepub const fn block_member_interaction() -> Self
pub const fn block_member_interaction() -> Self
Stops the member from using text, voice and other interactions.
discord.js counterpart: an AutoModerationActionOptions of type AutoModerationActionType.BlockMemberInteraction.