From 49189265ec1796ab0697b4b5010dc723ee5f9c87 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 5 May 2019 22:00:07 +0900 Subject: [PATCH] Added log channel messages to the bot --- bots/discord/discord.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bots/discord/discord.go b/bots/discord/discord.go index 4ec3d6f1..751a82cb 100644 --- a/bots/discord/discord.go +++ b/bots/discord/discord.go @@ -11,12 +11,18 @@ import ( ) // Session provides access to the Discord session. -var discord *discordgo.Session +var ( + discord *discordgo.Session + logChannel = "574579302843154442" +) func main() { - var err error + discord, err := discordgo.New() + + if err != nil { + panic(err) + } - discord, _ = discordgo.New() discord.Token = "Bot " + arn.APIKeys.Discord.Token // Verify a Token was provided @@ -41,6 +47,7 @@ func main() { defer discord.Close() defer arn.Node.Close() + defer discord.ChannelMessageSend(logChannel, "I'm feeling like shit today so I'm shutting down. B-baka!") // Receive events discord.AddHandler(OnMessageCreate) @@ -48,6 +55,7 @@ func main() { discord.AddHandler(OnGuildMemberRemove) // Wait for a CTRL-C + discord.ChannelMessageSend(logChannel, "Hooray, I'm up again! Did you miss me?") log.Printf("Tsundere is ready. Press CTRL-C to exit.") sc := make(chan os.Signal, 1) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)