generated from sebm253/bot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.go
44 lines (36 loc) · 1.01 KB
/
bot.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
package main
import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
"vs-helper/handlers"
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/cache"
"github.com/disgoorg/disgo/gateway"
"github.com/lmittmann/tint"
)
func main() {
logger := tint.NewHandler(os.Stdout, &tint.Options{
Level: slog.LevelInfo,
})
slog.SetDefault(slog.New(logger))
slog.Info("starting the bot...", slog.String("disgo.version", disgo.Version))
client, err := disgo.New(os.Getenv("VIRTUALSTREETS_HELPER_TOKEN"),
bot.WithGatewayConfigOpts(gateway.WithIntents(gateway.IntentsNone)),
bot.WithCacheConfigOpts(cache.WithCaches(cache.FlagsNone)),
bot.WithEventListeners(handlers.NewHandler()))
if err != nil {
panic(err)
}
defer client.Close(context.TODO())
if err := client.OpenGateway(context.TODO()); err != nil {
panic(err)
}
slog.Info("VirtualStreets Helper is now running.")
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-s
}