Skip to content

Commit

Permalink
Rename plurals to singulars and update data stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hi117 committed Aug 6, 2024
1 parent 5ac59ad commit 81871c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
27 changes: 20 additions & 7 deletions api/automoderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions discord/automoderation.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -51,7 +51,7 @@ type AutoModerationActionMetadata struct {
CustomMessage string `json:"custom_message,omitempty"`
}

type AutoModerationActionTypes uint32
type AutoModerationActionType uint32

const (
AutoModerationBlockMessage = 1 + iota
Expand All @@ -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"`
}
Expand All @@ -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
Expand Down

0 comments on commit 81871c2

Please sign in to comment.