forked from disgoorg/disgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_moderation.go
73 lines (63 loc) · 2.83 KB
/
auto_moderation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package rest
import (
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/rest/route"
"github.com/disgoorg/snowflake/v2"
)
var _ AutoModeration = (*autoModerationImpl)(nil)
func NewAutoModeration(client Client) AutoModeration {
return &autoModerationImpl{client: client}
}
type AutoModeration interface {
GetAutoModerationRules(guildID snowflake.ID, opts ...RequestOpt) ([]discord.AutoModerationRule, error)
GetAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, opts ...RequestOpt) (*discord.AutoModerationRule, error)
CreateAutoModerationRule(guildID snowflake.ID, ruleCreate discord.AutoModerationRuleCreate, opts ...RequestOpt) (*discord.AutoModerationRule, error)
UpdateAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, ruleUpdate discord.AutoModerationRuleUpdate, opts ...RequestOpt) (*discord.AutoModerationRule, error)
DeleteAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, opts ...RequestOpt) error
}
type autoModerationImpl struct {
client Client
}
func (s *autoModerationImpl) GetAutoModerationRules(guildID snowflake.ID, opts ...RequestOpt) (rules []discord.AutoModerationRule, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.GetAutoModerationRules.Compile(nil, guildID)
if err != nil {
return
}
err = s.client.Do(compiledRoute, nil, &rules, opts...)
return
}
func (s *autoModerationImpl) GetAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, opts ...RequestOpt) (rule *discord.AutoModerationRule, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.GetAutoModerationRule.Compile(nil, guildID, ruleID)
if err != nil {
return
}
err = s.client.Do(compiledRoute, nil, &rule, opts...)
return
}
func (s *autoModerationImpl) CreateAutoModerationRule(guildID snowflake.ID, ruleCreate discord.AutoModerationRuleCreate, opts ...RequestOpt) (rule *discord.AutoModerationRule, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.CreateAutoModerationRule.Compile(nil, guildID)
if err != nil {
return
}
err = s.client.Do(compiledRoute, ruleCreate, &rule, opts...)
return
}
func (s *autoModerationImpl) UpdateAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, ruleUpdate discord.AutoModerationRuleUpdate, opts ...RequestOpt) (rule *discord.AutoModerationRule, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.UpdateAutoModerationRule.Compile(nil, guildID, ruleID)
if err != nil {
return
}
err = s.client.Do(compiledRoute, ruleUpdate, &rule, opts...)
return
}
func (s *autoModerationImpl) DeleteAutoModerationRule(guildID snowflake.ID, ruleID snowflake.ID, opts ...RequestOpt) error {
compiledRoute, err := route.DeleteAutoModerationRule.Compile(nil, guildID, ruleID)
if err != nil {
return err
}
return s.client.Do(compiledRoute, nil, nil, opts...)
}