Added log channel messages to the bot

This commit is contained in:
Eduard Urbach 2019-05-05 22:00:07 +09:00
parent a6b2e85109
commit 49189265ec

View File

@ -11,12 +11,18 @@ import (
) )
// Session provides access to the Discord session. // Session provides access to the Discord session.
var discord *discordgo.Session var (
discord *discordgo.Session
logChannel = "574579302843154442"
)
func main() { func main() {
var err error discord, err := discordgo.New()
if err != nil {
panic(err)
}
discord, _ = discordgo.New()
discord.Token = "Bot " + arn.APIKeys.Discord.Token discord.Token = "Bot " + arn.APIKeys.Discord.Token
// Verify a Token was provided // Verify a Token was provided
@ -41,6 +47,7 @@ func main() {
defer discord.Close() defer discord.Close()
defer arn.Node.Close() defer arn.Node.Close()
defer discord.ChannelMessageSend(logChannel, "I'm feeling like shit today so I'm shutting down. B-baka!")
// Receive events // Receive events
discord.AddHandler(OnMessageCreate) discord.AddHandler(OnMessageCreate)
@ -48,6 +55,7 @@ func main() {
discord.AddHandler(OnGuildMemberRemove) discord.AddHandler(OnGuildMemberRemove)
// Wait for a CTRL-C // 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.") log.Printf("Tsundere is ready. Press CTRL-C to exit.")
sc := make(chan os.Signal, 1) sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)