go: discord/backend: Use Minecraft username as fallback for member search

master
Luther Wen Xu 2019-10-16 12:35:02 +07:00
parent 7d29b0f923
commit 34daaa83cb
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 13 additions and 0 deletions

@ -6,6 +6,7 @@ import (
"github.com/bwmarrin/discordgo"
"TerraOceanBot/db"
"TerraOceanBot/discord/config"
)
@ -59,5 +60,17 @@ func GetMemberFromUserFriendlyName(s *discordgo.Session, user string) (*discordg
return v, nil
}
}
for _, v := range allMembers {
mcUsername, err := db.GetMinecraftUsername(v.User.ID)
if err == db.ErrNotFound {
continue
}
if err != nil {
return nil, err
}
if mcUsername == user {
return v, nil
}
}
return nil, ErrMemberNotFound
}