Skip to content

Commit

Permalink
Handling unknown user better
Browse files Browse the repository at this point in the history
  • Loading branch information
STollenaar committed May 5, 2023
1 parent 8f5ad78 commit 1ba9c4f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/commands/maxCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ func MaxCommand(bot *discordgo.Session, interaction *discordgo.InteractionCreate
if targetUser == nil {
t, _ := bot.GuildMember(interaction.GuildID, maxWord.Author)
if t == nil {
response = fmt.Sprintf("%s has used the word \"%s\" the most, and is used %d time(s) \n", maxWord.Author, maxWord.Word.Word, maxWord.Word.Count)
targetUser = &discordgo.User{Username: "Unknown User", ID: maxWord.Author}
// response = fmt.Sprintf("%s has used the word \"%s\" the most, and is used %d time(s) \n", maxWord.Author, maxWord.Word.Word, maxWord.Word.Count)
} else {
targetUser = t.User
response = fmt.Sprintf("%s has used the word \"%s\" the most, and is used %d time(s) \n", targetUser.Mention(), maxWord.Word.Word, maxWord.Word.Count)
}
response = fmt.Sprintf("%s has used the word \"%s\" the most, and is used %d time(s) \n", targetUser.Mention(), maxWord.Word.Word, maxWord.Word.Count)
}
} else {
response = fmt.Sprintf("You have used the word \"%s\" the most, and is used %d time(s) \n", maxWord.Word.Word, maxWord.Word.Count)
Expand Down

0 comments on commit 1ba9c4f

Please sign in to comment.