forked from botlabs-gg/yagpdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autorole.go
49 lines (39 loc) · 1.33 KB
/
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
42
43
44
45
46
47
48
49
package autorole
import (
"github.com/jonas747/discordgo"
"github.com/jonas747/yagpdb/common"
"github.com/jonas747/yagpdb/common/config"
)
var confDisableNonPremiumRetroActiveAssignment = config.RegisterOption("yagpdb.autorole.non_premium_retroactive_assignment", "Wether to enable retroactive assignemnt on non premium guilds", true)
var logger = common.GetPluginLogger(&Plugin{})
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) PluginInfo() *common.PluginInfo {
return &common.PluginInfo{
Name: "Autorole",
SysName: "autorole",
Category: common.PluginCategoryMisc,
}
}
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 {
logger.WithError(err).WithField("guild", guildID).Error("failed retreiving autorole config")
}
return conf, err
}