-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (44 loc) · 849 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
51
52
53
54
55
package main
import (
"encoding/json"
"fmt"
"io"
"os"
"arkhamhhorrorlcg/bot"
)
func main() {
fmt.Println("Initializing the Arkham Horror LCG bot...")
// parse config.json file, get the token
f, err := os.Open("config.json")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer f.Close()
bs, err := io.ReadAll(f)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
type token struct {
Value string `json:"token"`
}
var t token
err = json.Unmarshal(bs, &t)
if err != nil {
fmt.Println(err)
os.Exit(3)
}
fmt.Println("Successfully parsed the token from config.json file.")
// Start the bot
fmt.Println("Starting the bot...")
b := bot.NewDiscordBot()
serverDown, err := b.Run(t.Value)
if err != nil {
fmt.Println(err)
os.Exit(4)
}
defer b.Close()
<-serverDown
fmt.Println("Shutting down the bot...")
}