From 0310008bceee4939e2425e47886e453bf96ee8dc Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Tue, 6 Apr 2021 18:50:06 -0400 Subject: [PATCH] Allow usernames pt 2 --- main.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index ef83f05..6e5193f 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "os" "os/signal" "path/filepath" + "strconv" "strings" "syscall" "time" @@ -429,22 +430,18 @@ func idFromUsername(username string) string { } func findVerification(s *discordgo.Session, m *discordgo.MessageCreate) { + defer log.PanicSafe() parts := strings.Split(m.Content, " ") discordId := parts[1] + _, err := strconv.Atoi(discordId) + if err != nil { + discordId = idFromUsername(discordId) + } user, err := s.GuildMember(config.GuildID, discordId) - uidFound := true if err != nil { log.LogErrorType(err) - uidFound = false - } - if !uidFound { - discordId = idFromUsername(discordId) - user, err = s.GuildMember(config.GuildID, discordId) - uidFound = true - if err != nil { - log.LogErrorType(err) - } } + matches, err := filepath.Glob(fmt.Sprintf("./verifications/*%+v*", discordId)) if err != nil { log.LogErrorType(err)