package handlers import ( "errors" "fmt" "github.com/mr1hm/go-discord-bot/internal/tft" ) type TFTCommonMatches struct { Matches map[string][]string // Map of common match IDs between all accounts } type TFTCompareError struct { Err error } func (ae *TFTCompareError) Error() string { return fmt.Sprintf("[ API Handler ] Error: %v", ae.Err) } // GetTFTCommonGames simply gets all matches from MatchIDs that registered users have in common func (cm *TFTCommonMatches) GetTFTCommonGames() error { common_matches := TFTCommonMatches{ Matches: make(map[string][]string), } for puuid, amd := range tft.UserData.Data { if len(amd.Matches) > 0 { for _, mid := range amd.Matches { if _, exists := common_matches.Matches[mid]; !exists { common_matches.Matches[mid] = append(common_matches.Matches[mid], puuid) } } } } return &TFTCompareError{ Err: errors.New(fmt.Sprintf("GetCommonGames() - Error: \n")), } // return nil }