From 34daaa83cb1e09859af4aeb79379abee095805c5 Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Wed, 16 Oct 2019 12:35:02 +0800 Subject: [PATCH] go: discord/backend: Use Minecraft username as fallback for member search --- GoBot/discord/backend/members.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/GoBot/discord/backend/members.go b/GoBot/discord/backend/members.go index 0a4af6c..754b6e2 100644 --- a/GoBot/discord/backend/members.go +++ b/GoBot/discord/backend/members.go @@ -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 }