forked from botlabs-gg/yagpdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autorole.go
41 lines (33 loc) · 984 Bytes
/
autorole.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
package autorole
import (
"github.com/jonas747/discordgo"
"github.com/jonas747/yagpdb/common"
"github.com/sirupsen/logrus"
)
func KeyGeneral(guildID int64) string { return "autorole:" + discordgo.StrID(guildID) + ":general" }
func KeyProcessing(guildID int64) string {
return "autorole:" + discordgo.StrID(guildID) + ":processing"
}
type Plugin struct{}
func (p *Plugin) Name() string {
return "Autorole"
}
func RegisterPlugin() {
p := &Plugin{}
common.RegisterPlugin(p)
}
type GeneralConfig struct {
Role int64 `json:",string" valid:"role,true"`
RequiredDuration int
RequiredRoles []int64 `valid:"role,true"`
IgnoreRoles []int64 `valid:"role,true"`
OnlyOnJoin bool
}
func GetGeneralConfig(guildID int64) (*GeneralConfig, error) {
conf := &GeneralConfig{}
err := common.GetRedisJson(KeyGeneral(guildID), conf)
if err != nil {
logrus.WithError(err).WithField("guild", guildID).Error("failed retreiving autorole config")
}
return conf, err
}