|
|
|
@ -2,19 +2,14 @@ package discord
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"os/signal"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
|
|
|
|
|
|
"TerraOceanBot/discord/modules"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func StartBot(token string, wg *sync.WaitGroup) {
|
|
|
|
|
defer wg.Done()
|
|
|
|
|
func StartBot(token string, kill chan bool) {
|
|
|
|
|
dg, err := discordgo.New("Bot " + strings.TrimSpace(token))
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
@ -32,10 +27,11 @@ func StartBot(token string, wg *sync.WaitGroup) {
|
|
|
|
|
|
|
|
|
|
fmt.Println("Bot is now running. Press CTRL-C to exit.")
|
|
|
|
|
go modules.ListenToVoteFinishes(dg)
|
|
|
|
|
sc := make(chan os.Signal, 1)
|
|
|
|
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
|
|
|
|
<-sc
|
|
|
|
|
|
|
|
|
|
<-kill
|
|
|
|
|
|
|
|
|
|
dg.Close()
|
|
|
|
|
fmt.Println("Discordgo exited successfully.")
|
|
|
|
|
|
|
|
|
|
<-kill
|
|
|
|
|
}
|
|
|
|
|