package discord import ( "fmt" "strings" "github.com/bwmarrin/discordgo" "TerraOceanBot/discord/backend" "TerraOceanBot/discord/modules" ) func StartBot(token string, kill chan bool) { dg, err := discordgo.New("Bot " + strings.TrimSpace(token)) if err != nil { panic(err) } dg.AddHandler(ProcessCommand) dg.AddHandler(modules.CheckForReact) dg.AddHandler(modules.CheckForVote) if err := dg.Open(); err != nil { panic(err) } fmt.Println("Bot is now running. Press CTRL-C to exit.") go modules.ListenToVoteFinishes(dg) go backend.UpdateVoiceChannelState(dg) <-kill dg.Close() fmt.Println("Discordgo exited successfully.") <-kill }