-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (41 loc) · 1019 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 (
"github.com/bwmarrin/discordgo"
"github.com/joho/godotenv"
"log"
"os"
"os/signal"
"syscall"
"velxBOT/commands/fun"
"velxBOT/commands/help"
"velxBOT/commands/moderation"
)
func main() {
if err := godotenv.Load(".env"); err != nil {
log.Fatalf("Some error occured. Err: %s", err)
}
velx, err := discordgo.New("Bot " + os.Getenv("TOKEN"))
if err != nil {
log.Fatal("Can't create Discord session, ", err)
return
}
//Handlers
velx.AddHandler(fun.HandleFunCommands)
velx.AddHandler(moderation.HandleModerationCommands)
velx.AddHandler(help.HandleHelpCommand)
velx.Identify.Intents = discordgo.IntentsAllWithoutPrivileged
err = velx.Open()
if err != nil {
log.Fatal("Can't open bot, ", err)
return
}
defer velx.Close()
//Cleanly close down the Discord session
log.Println("Bot is running!")
waitForTerminationSignal()
}
func waitForTerminationSignal() {
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
}