forked from botlabs-gg/yagpdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
53 lines (44 loc) · 1.16 KB
/
plugin.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
package bot
import (
"github.com/jonas747/discordgo"
"github.com/jonas747/dutil/dstate"
"github.com/jonas747/yagpdb/common"
"github.com/sirupsen/logrus"
"sync"
)
const (
// How long after removing a guild the config for it gets cleared
GuildRemoveConfigExpire = 60 * 60 * 24 // <- 1 day
)
// Used for deleting configuration about servers
type RemoveGuildHandler interface {
RemoveGuild(guildID int64) error
}
// Used for intializing stuff for new servers
type NewGuildHandler interface {
NewGuild(guild *discordgo.Guild) error
}
// Fired when the bot it starting up, not for the webserver
type BotInitHandler interface {
BotInit()
}
// Fired after the bot has connected all shards
type BotStartedHandler interface {
BotStarted()
}
type BotStopperHandler interface {
StopBot(wg *sync.WaitGroup)
}
type ShardMigrationHandler interface {
GuildMigrated(guild *dstate.GuildState, toThisSlave bool)
}
func EmitGuildRemoved(guildID int64) {
for _, v := range common.Plugins {
if remover, ok := v.(RemoveGuildHandler); ok {
err := remover.RemoveGuild(guildID)
if err != nil {
logrus.WithError(err).Error("Error Running RemoveGuild on ", v.Name())
}
}
}
}