Moved startup status to ready handler.

pull/1/head
pocketjawa 2019-04-27 02:27:24 -04:00
parent c6151323ee
commit 87360672f0
1 changed files with 14 additions and 7 deletions

View File

@ -38,6 +38,9 @@ func main() {
return return
} }
//Handlers
Session.AddHandler(ready)
//Open a connection to Discord //Open a connection to Discord
err = Session.Open() err = Session.Open()
if err != nil { if err != nil {
@ -47,15 +50,19 @@ func main() {
//Wait for a CTRL-C //Wait for a CTRL-C
log.Printf("Now running. Press CTRL-C to exit.") log.Printf("Now running. Press CTRL-C to exit.")
if *testPtr == true {
Session.ChannelMessageSend(bot_channel, "Test complete: discord-buttsbot-go")
log.Printf("Test successful! Now quiting.")
Session.Close()
os.Exit(0)
}
Session.ChannelMessageSend(bot_channel, "This isn't a butt...")
sc := make(chan os.Signal, 1) sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc <-sc
Session.Close() Session.Close()
} }
func ready(s *discordgo.Session, event *discordgo.Ready) {
if *testPtr == true {
s.ChannelMessageSend(bot_channel, "Test complete: discord-buttsbot-go")
log.Printf("Test successful! Now quiting.")
s.Close()
os.Exit(0)
}
s.UpdateStatus(0, "with butts!")
s.ChannelMessageSend(bot_channel, "This isn't a butt...")
}