-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
50 lines (39 loc) · 863 Bytes
/
main.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
package main
import (
"os"
"os/signal"
"syscall"
"github.com/bwmarrin/discordgo"
"github.com/zekrotja/ken"
"github.com/zekrotja/ken/examples/middlewares/commands"
"github.com/zekrotja/ken/examples/middlewares/middlewares"
"github.com/zekrotja/ken/store"
)
func must(err error) {
if err != nil {
panic(err)
}
}
func main() {
token := os.Getenv("TOKEN")
session, err := discordgo.New("Bot " + token)
if err != nil {
panic(err)
}
defer session.Close()
k, err := ken.New(session, ken.Options{
CommandStore: store.NewDefault(),
})
must(err)
must(k.RegisterCommands(
new(commands.KickCommand),
))
must(k.RegisterMiddlewares(
new(middlewares.PermissionsMiddleware),
))
defer k.Unregister()
must(session.Open())
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
}