Add logging for messages erroring out
This commit is contained in:
@ -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()
|
||||
}
|
||||
|
||||
|
||||
6
main.go
6
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user