aboutsummaryrefslogtreecommitdiff
path: root/thulani.go
blob: d64cb7c83e02b1e532b634e1d548e88043fe0d9c (plain) (blame)
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
package thulani

import (
	"os"
	"os/signal"
	"syscall"

	"github.com/bwmarrin/discordgo"
)

func Run(conf *Config) {
	dg, err := discordgo.New("Bot " + conf.Token)
	handle(err)

	dg.AddHandler(onReady)
	dg.Open()

	sc := make(chan os.Signal, 1)
	signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
	<-sc

	dg.Close()
}

func onReady(s *discordgo.Session, m *discordgo.Ready) {
	log.Debugf("Logged in as %v (%v)", m.User.Username, m.User.ID)
}