-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.go
55 lines (44 loc) · 1.12 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
45
46
47
48
49
50
51
52
53
54
55
//go:generate goversioninfo -icon=_src/Neon.ico
package main
import (
"fmt"
"os"
"os/signal"
"github.com/bwmarrin/discordgo"
session "github.com/shaunsational/go-bot/lib/session"
utils "github.com/shaunsational/go-bot/lib/utils"
commands "github.com/shaunsational/go-bot/lib/commands"
)
var (
conf *session.Config
discord *discordgo.Session
err error
)
func init() {
conf, discord = session.Get()
}
func main() {
slash := commands.Load()
// open session
err = discord.Open()
if err != nil {
fmt.Println(" Error opening connection,", err)
} else {
utils.StartupAnim(conf.AppID, conf.Permissions)
sigalert := make(chan os.Signal, 1)
signal.Notify(sigalert)
<-sigalert
if conf.Cleanup == "true" { // }
for _, v := range slash {
utils.LoadingText("Removing commands")
err := discord.ApplicationCommandDelete(discord.State.User.ID, conf.GuildID, v.ID)
if err != nil {
fmt.Println(" - Cannot delete '%v' command: %v", v.Name, err)
} else {
fmt.Println(" Commands removed ")
}
}
}
discord.Close() // close session, after function termination
}
}