diff --git a/api/automoderation.go b/api/automoderation.go index 79a70c56..cfb21bc9 100644 --- a/api/automoderation.go +++ b/api/automoderation.go @@ -40,9 +40,22 @@ func (c *Client) CreateAutoModerationRule(guildID discord.GuildID, rule discord. } type ModifyAutoModerationRuleData struct { - GuildID discord.GuildID - RuleID discord.AutoModerationRuleID - Rule discord.AutoModerationRule + GuildID discord.GuildID `json:"-"` + RuleID discord.AutoModerationRuleID `json:"-"` + // the rule name + Name string `json:"name"` + // the event type + EventType discord.AutoModerationEventType `json:"event_type"` + // the trigger metadata + TriggerMetadata discord.AutoModerationTriggerMetadata `json:"triggr_metadata,omitempty"` + // the actions which will execute when the rule is triggered + Actions []discord.AutoModerationAction `json:"actions"` + // whether the rule is enabled + Enabled bool `json:"enabled"` + // the role ids that should not be affected by the rule (Maximum of 20) + ExemptRules []discord.RoleID `json:"exempt_roles"` + // the channel ids that should not be affected by the rule (Maximum of 50) + ExemptChannels []discord.ChannelID `json:"exempt_channels"` AuditLogReason } @@ -56,15 +69,15 @@ type ModifyAutoModerationRuleData struct { func (c *Client) ModifyAutoModerationRule(data ModifyAutoModerationRuleData) (*discord.AutoModerationRule, error) { var ret *discord.AutoModerationRule return ret, c.RequestJSON(&ret, "PATCH", EndpointGuilds+data.GuildID.String()+"/auto-moderation/rules/"+data.RuleID.String(), - httputil.WithJSONBody(data.Rule), + httputil.WithJSONBody(data), httputil.WithHeaders(data.Header()), ) } type DeleteAutoModerationRuleData struct { - GuildID discord.GuildID - RuleID discord.AutoModerationRuleID - AuditLogReason + GuildID discord.GuildID + RuleID discord.AutoModerationRuleID + AuditLogReason `json:"-"` } // DeleteAutoModerationRule deletes a rule. Returns a 204 on success. Fires an Auto Moderation Rule Delete Gateway event. diff --git a/discord/automoderation.go b/discord/automoderation.go index 0ba70372..b6a24cd2 100644 --- a/discord/automoderation.go +++ b/discord/automoderation.go @@ -1,23 +1,23 @@ package discord -type AutoModerationEventTypes uint32 +type AutoModerationEventType uint32 const ( - AutoModerationMessageSend AutoModerationEventTypes = 1 + iota + AutoModerationMessageSend AutoModerationEventType = 1 + iota AutoModerationMemberUpdate ) -type AutoModerationTriggerTypes uint32 +type AutoModerationTriggerType uint32 const ( - AutoModerationKeyword AutoModerationTriggerTypes = 1 + iota + AutoModerationKeyword AutoModerationTriggerType = 1 + iota AutoModerationSpam AutoModerationKeywordPreset AutoModerationMentionSpam AutoModerationMemberProfile ) -type AutoModerationKeywordPresetTypes uint32 +type AutoModerationKeywordPresetType uint32 const ( AutoModeratorProfanity = 1 + iota @@ -31,7 +31,7 @@ type AutoModerationTriggerMetadata struct { // regular expression patterns which will be matched against content (Maximum of 10) RegexPatterns []string `json:"regex_patterns"` // the internally pre-defined wordsets which will be searched for in content - Presets []AutoModerationKeywordPresetTypes `json:"presets"` + Presets []AutoModerationKeywordPresetType `json:"presets"` // substrings which should not trigger the rule (Maximum of 100 or 1000) AllowList []string `json:"allow_list"` // total number of unique role and user mentions allowed per message (Maximum of 50) @@ -51,7 +51,7 @@ type AutoModerationActionMetadata struct { CustomMessage string `json:"custom_message,omitempty"` } -type AutoModerationActionTypes uint32 +type AutoModerationActionType uint32 const ( AutoModerationBlockMessage = 1 + iota @@ -62,7 +62,7 @@ const ( type AutoModerationAction struct { // the type of action - Type AutoModerationActionTypes `json:"type"` + Type AutoModerationActionType `json:"type"` // additional metadata needed during execution for this specific action type Metadata AutoModerationActionMetadata `json:"metadata,omitempty"` } @@ -77,9 +77,9 @@ type AutoModerationRule struct { // the user which first created this rule CreatorID UserID `json:"creator_id,omitempty"` // the rule event type - EventType AutoModerationEventTypes `json:"event_type"` + EventType AutoModerationEventType `json:"event_type"` // the rule trigger type - TriggerType AutoModerationTriggerTypes + TriggerType AutoModerationTriggerType // the rule trigger metadata TriggerMetadata AutoModerationTriggerMetadata `json:"trigger_metadata,omitempty"` // the actions which will execute when the rule is triggered