-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (34 loc) · 899 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
package main
import (
"fmt"
"github.com/bwmarrin/discordgo"
ready "github.com/mrtuxa/discordbotgo-boty/events"
"github.com/mrtuxa/discordbotgo-boty/utils/merror"
"os"
"os/signal"
"syscall"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
}
merror.CheckFatal(err, "GoDotenv", "Can't load environment")
envToken := os.Getenv("TOKEN")
if envToken == "" {
os.Exit(1)
}
token := "Bot" + envToken
client, err := discordgo.New(token)
merror.DisGoClientError(err)
client.AddHandler(ready.ReadyFunc)
client.Identify.Intents = discordgo.IntentsAll
err = client.Open()
merror.CheckPrintReturn(err, "[DiscordGo] Client:", "error opening connection", err)
fmt.Println("Bot is now running!")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
err = client.Close()
merror.CheckReturn(err)
}