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