KnutZuidema / golio

League of Legends, Legends of Runeterra and Valorant API client library for Go
MIT License
72 stars 29 forks source link

datadragon.ChampionData.ID returns name of the Champion instead of the actual ID. #44

Closed ghost closed 3 years ago

ghost commented 3 years ago

I am currently working on a small scale Discord Bot with some League of Legends functionality and stumbled opon a problem with the DataDragon.GetChampionByID() function. To my knowledge every champ should have an numerical ID, for example Vayne has the ID 67, as returned by the ChampionMastery data, but using the ByID function returns nothing when passing in 67.

A sample:

func main() {
    client := golio.NewClient("KEY",
        golio.WithRegion(api.RegionEuropeWest))
    summoner, _ := client.Riot.Summoner.GetByName("Herndl")
    masteryList, _ := client.Riot.LoL.ChampionMastery.List(summoner.ID)
    fmt.Printf("ID: %v\n", masteryList[0].ChampionID)
    champion, _ := client.DataDragon.GetChampion("Vayne")
    fmt.Printf("ID without ByID: %s\n", champion.ID)
    IdToString := fmt.Sprintf("%v", masteryList[0].ChampionID) // convert int to string
    championByID, err := client.DataDragon.GetChampionByID(IdToString)
    fmt.Printf("%T\n", IdToString)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("ID with ByID: %s", championByID.ID)
}

Output of the sample:

ID: 67
ID without ByID: Vayne
string
not found
ID with ByID:
ghost commented 3 years ago

After looking further into that, I found out that the library I was using before changed up some terms and caused some confusion on my side! Now I know that the Key is what I want to use, but it doesn't seem like there is a function to fetch champions with the Key. Anyway, sorry for the inconvenience!