-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (29 loc) · 683 Bytes
/
main.go
File metadata and controls
33 lines (29 loc) · 683 Bytes
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
package main
import (
"github.com/BurntSushi/toml"
"github.com/bwmarrin/discordgo"
flag "github.com/spf13/pflag"
"os"
"os/signal"
)
var dish Dish
func main() {
file := flag.StringP("dish", "d", "", ".dish file")
flag.Parse()
data, err := os.ReadFile(*file)
if err != nil {
exitOnError(err)
}
err = toml.Unmarshal(data, &dish)
exitOnError(err)
session, err := discordgo.New("Bot " + dish.Bot.Token)
exitOnError(err)
session.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuildMessages)
session.AddHandler(handler)
err = session.Open()
exitOnError(err)
sc := make(chan os.Signal, 1)
signal.Notify(sc, os.Interrupt, os.Kill)
<-sc
session.Close()
}