forked from botlabs-gg/yagpdb
-
Notifications
You must be signed in to change notification settings - Fork 5
/
models.go
121 lines (97 loc) · 2.65 KB
/
models.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package moderation
import (
"context"
"github.com/jonas747/yagpdb/common"
"github.com/jonas747/yagpdb/common/configstore"
"github.com/jonas747/yagpdb/common/pubsub"
"github.com/lib/pq"
"strconv"
"time"
)
type Config struct {
configstore.GuildConfigModel
// Kick command
KickEnabled bool
KickCmdRoles pq.Int64Array `gorm:"type:bigint[]" valid:"role,true"`
DeleteMessagesOnKick bool
KickReasonOptional bool
KickMessage string `valid:"template,1900"`
// Ban
BanEnabled bool
BanCmdRoles pq.Int64Array `gorm:"type:bigint[]" valid:"role,true"`
BanReasonOptional bool
BanMessage string `valid:"template,1900"`
// Mute/unmute
MuteEnabled bool
MuteCmdRoles pq.Int64Array `gorm:"type:bigint[]" valid:"role,true"`
MuteRole string `valid:"role,true"`
MuteReasonOptional bool
UnmuteReasonOptional bool
MuteManageRole bool
MuteRemoveRoles pq.Int64Array `gorm:"type:bigint[]" valid:"role,true"`
MuteIgnoreChannels pq.Int64Array `gorm:"type:bigint[]" valid:"channel,true"`
// Warn
WarnCommandsEnabled bool
WarnCmdRoles pq.Int64Array `gorm:"type:bigint[]" valid:"role,true"`
WarnIncludeChannelLogs bool
WarnSendToModlog bool
// Misc
CleanEnabled bool
ReportEnabled bool
ActionChannel string `valid:"channel,true"`
ReportChannel string `valid:"channel,true"`
LogUnbans bool
LogBans bool
}
func (c *Config) IntMuteRole() (r int64) {
r, _ = strconv.ParseInt(c.MuteRole, 10, 64)
return
}
func (c *Config) IntActionChannel() (r int64) {
r, _ = strconv.ParseInt(c.ActionChannel, 10, 64)
return
}
func (c *Config) IntReportChannel() (r int64) {
r, _ = strconv.ParseInt(c.ReportChannel, 10, 64)
return
}
func (c *Config) GetName() string {
return "moderation"
}
func (c *Config) TableName() string {
return "moderation_configs"
}
func (c *Config) Save(guildID int64) error {
c.GuildID = guildID
err := configstore.SQL.SetGuildConfig(context.Background(), c)
if err != nil {
return err
}
pubsub.Publish("mod_refresh_mute_override", guildID, nil)
return nil
}
type WarningModel struct {
common.SmallModel
GuildID int64 `gorm:"index"`
UserID string
AuthorID string
// Username and discrim for author incase he/she leaves
AuthorUsernameDiscrim string
Message string
LogsLink string
}
func (w *WarningModel) TableName() string {
return "moderation_warnings"
}
type MuteModel struct {
common.SmallModel
ExpiresAt time.Time
GuildID int64 `gorm:"index"`
UserID int64
AuthorID int64
Reason string
RemovedRoles pq.Int64Array `gorm:"type:bigint[]"`
}
func (m *MuteModel) TableName() string {
return "muted_users"
}