Browse Source

Add logging for messages erroring out

master
Gregory Rudolph 2 years ago
parent
commit
283f8dbf65
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 8
      discordEvents.go
  2. 6
      main.go

8
discordEvents.go

@ -14,24 +14,32 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {
defer log.PanicSafe() defer log.PanicSafe()
log.LogDebug("Member has been updated")
for role := range m.Roles { for role := range m.Roles {
if fmt.Sprintf("%+v", role) == config.MonitorRole { if fmt.Sprintf("%+v", role) == config.MonitorRole {
log.LogDebug("Role found, Monitor Role")
s.ChannelMessageSend(config.AdminChannel, "New unverified user detected.") 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())) 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.Unverified[m.User.ID] = time.Now()
config.Probations[m.User.ID] = time.Now() config.Probations[m.User.ID] = time.Now()
saveConfig() saveConfig()
return
} }
log.LogDebug("Monitor Role not found")
} }
} }
func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) { func guildMemberAdd(s *discordgo.Session, m *discordgo.GuildMemberAdd) {
defer log.PanicSafe() defer log.PanicSafe()
log.LogDebug("Adding user to Unverified and Probations")
config.Unverified[m.User.ID] = time.Now() config.Unverified[m.User.ID] = time.Now()
config.Probations[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) 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())) 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() saveConfig()
} }

6
main.go

@ -168,17 +168,23 @@ func cleanSocials(s *discordgo.Session) {
func verifyMember(s *discordgo.Session, u discordgo.User) { func verifyMember(s *discordgo.Session, u discordgo.User) {
defer log.PanicSafe() defer log.PanicSafe()
log.LogDebug("Adding verified roll")
s.GuildMemberRoleAdd(config.GuildID, u.ID, config.VerifiedRole) s.GuildMemberRoleAdd(config.GuildID, u.ID, config.VerifiedRole)
log.LogDebug("Removing monitor role")
s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole) s.GuildMemberRoleRemove(config.GuildID, u.ID, config.MonitorRole)
log.LogDebug("Creating PM channel")
st, err := s.UserChannelCreate(u.ID) st, err := s.UserChannelCreate(u.ID)
if err != nil { if err != nil {
log.LogErrorType(err) log.LogErrorType(err)
} }
log.LogDebug("Sending acceptance message!")
s.ChannelMessageSend(st.ID, "Your verification has been accepted, welcome!") 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())) 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 { if err != nil {
log.LogErrorType(err) log.LogErrorType(err)
} }
log.LogDebug("Storing introMsg ID to be deleted later")
introMsg[u.ID] = m.ID introMsg[u.ID] = m.ID
} }

Loading…
Cancel
Save