From cce07513f35aebb9f6750e575d0684d75c9393bd Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Tue, 11 Jan 2022 09:37:18 -0500 Subject: [PATCH] Add logging for messages erroring out --- discordEvents.go | 2 +- discordMessage.go | 1 - main.go | 23 ++++++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/discordEvents.go b/discordEvents.go index 32a8633..0272940 100644 --- a/discordEvents.go +++ b/discordEvents.go @@ -9,7 +9,7 @@ import ( func ready(s *discordgo.Session, event *discordgo.Ready) { // Set the playing status. - s.UpdateGameStatus(0, fmt.Sprintf("DreamDaddy v%+v %+v", version, gitCommit)) + s.UpdateGameStatus(0, fmt.Sprintf("DreamDaddy rev %+v", gitCommit)) } func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { diff --git a/discordMessage.go b/discordMessage.go index afb8718..0573eaf 100644 --- a/discordMessage.go +++ b/discordMessage.go @@ -54,7 +54,6 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { } if m.ChannelID != config.AdminChannel { - lastActiveChan = m.ChannelID lastActiveTime = time.Now() if len(m.Attachments) > 0 { activeInteraction(s, m.Author.ID) diff --git a/main.go b/main.go index 59c1f9c..a920349 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,6 @@ var ( bump = true config Config log = loggy.NewLogger(config.LogOpts) - lastActiveChan string lastActiveTime time.Time token string configFile string @@ -28,7 +27,6 @@ var ( lastPM = make(map[string]time.Time) introMsg = make(map[string]string) quotes = []string{"The hardest choices require the strongest wills.", "You're strong, but I could snap my fingers and you'd all cease to exist.", "Fun isn't something one considers when balancing the universe. But this... does put a smile on my face.", "Perfectly balanced, as all things should be.", "I am inevitable."} - version = "git" gitCommit string commands []Command ) @@ -50,7 +48,6 @@ func main() { log = loggy.NewLogger(config.LogOpts) startupTime = time.Now() lastActiveTime = time.Now() - lastActiveChan = config.AdminChannel if token == "" { log.LogPanic("No token provided. Please run: disgord-thanos -t ") } @@ -173,15 +170,24 @@ func verifyMember(s *discordgo.Session, u discordgo.User) { defer log.PanicSafe() s.GuildMemberRoleAdd(config.GuildID, u.ID, config.VerifiedRole) s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole) - st, _ := s.UserChannelCreate(u.ID) + st, err := s.UserChannelCreate(u.ID) + if err != nil { + log.LogErrorType(err) + } s.ChannelMessageSend(st.ID, "Your verification has been accepted, welcome!") - m, _ := s.ChannelMessageSend(config.IntroChann, fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention())) + m, err := s.ChannelMessageSend(config.IntroChann, fmt.Sprintf("Welcome %+v please introduce yourself! :) feel free to check out <#710557387937022034> to tag your roles. Also please mute any channels you are not interested in!", u.Mention())) + if err != nil { + log.LogErrorType(err) + } introMsg[u.ID] = m.ID } func rejectVerification(s *discordgo.Session, u discordgo.User) { defer log.PanicSafe() - st, _ := s.UserChannelCreate(u.ID) + st, err := s.UserChannelCreate(u.ID) + if err != nil { + log.LogErrorType(err) + } if st != nil { s.ChannelMessageSend(st.ID, fmt.Sprintf("Your verification has been rejected. This means it did not clearly show your face, with your pinkie finger held to the corner of your mouth, or the photo looked edited/filtered. No filters will be accepted.\n\nPlease try again before ", time.Now().Add(1*time.Hour).Unix())) } @@ -190,7 +196,10 @@ func rejectVerification(s *discordgo.Session, u discordgo.User) { func requestAge(s *discordgo.Session, u discordgo.User) { defer log.PanicSafe() - st, _ := s.UserChannelCreate(u.ID) + st, err := s.UserChannelCreate(u.ID) + if err != nil { + log.LogErrorType(err) + } s.ChannelMessageSend(st.ID, "What is your ASL? (Age/Sex/Language) Please note, this is NOT requesting your gender, but your biological sex. Gender is a social construct, sex is biology and in the context of pornographic images more important.") }