From 283f8dbf65917f9d2a6148090ce7d24a0ed742db Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Tue, 11 Jan 2022 10:12:09 -0500 Subject: [PATCH] Add logging for messages erroring out --- discordEvents.go | 8 ++++++++ main.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/discordEvents.go b/discordEvents.go index 0272940..c903fe9 100644 --- a/discordEvents.go +++ b/discordEvents.go @@ -14,24 +14,32 @@ func ready(s *discordgo.Session, event *discordgo.Ready) { func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { defer log.PanicSafe() + log.LogDebug("Member has been updated") for role := range m.Roles { if fmt.Sprintf("%+v", role) == config.MonitorRole { + log.LogDebug("Role found, Monitor Role") s.ChannelMessageSend(config.AdminChannel, "New unverified user detected.") s.ChannelMessageSend(config.MonitorChann, fmt.Sprintf("Welcome %+v, you may PM me your verification, or I will ban you in an hour!\nSay \"!rules\" in this channel, without quotes for the rules. You may private/direct message me for verification instructions.\n\nYou will not be able to read/see other channels or users until you verify.", m.User.Mention())) config.Unverified[m.User.ID] = time.Now() config.Probations[m.User.ID] = time.Now() saveConfig() + return } + log.LogDebug("Monitor Role not found") } } func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) { defer log.PanicSafe() + log.LogDebug("Adding user to Unverified and Probations") config.Unverified[m.User.ID] = time.Now() config.Probations[m.User.ID] = time.Now() + log.LogDebug("Giving user monitor role") s.GuildMemberRoleAdd(config.GuildID, m.User.ID, config.MonitorRole) + log.LogDebug("Sending Monitored message") s.ChannelMessageSend(config.MonitorChann, fmt.Sprintf("Welcome %+v, you may PM me your verification, or I will ban you in an hour!\nSay \"!rules\" in this channel, without quotes for the rules. You may private/direct message me for verification instructions.\n\nYou will not be able to read/see other channels or users until you verify.", m.User.Mention())) + log.LogDebug("Calling saveConfig") saveConfig() } diff --git a/main.go b/main.go index a920349..59ff46c 100644 --- a/main.go +++ b/main.go @@ -168,17 +168,23 @@ func cleanSocials(s *discordgo.Session) { func verifyMember(s *discordgo.Session, u discordgo.User) { defer log.PanicSafe() + log.LogDebug("Adding verified roll") s.GuildMemberRoleAdd(config.GuildID, u.ID, config.VerifiedRole) + log.LogDebug("Removing monitor role") s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole) + log.LogDebug("Creating PM channel") st, err := s.UserChannelCreate(u.ID) if err != nil { log.LogErrorType(err) } + log.LogDebug("Sending acceptance message!") s.ChannelMessageSend(st.ID, "Your verification has been accepted, welcome!") + log.LogDebug("Sending Intro message") 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) } + log.LogDebug("Storing introMsg ID to be deleted later") introMsg[u.ID] = m.ID }