simwai / lol-ranks-bot

A Discord bot to assign roles based on League of Legends Rank
4 stars 6 forks source link

Exchange Summoner Name To Riot ID #28

Open RTBGG opened 7 months ago

RTBGG commented 7 months ago

I just tried using the bot and noticed it doesnt work (see error message below), however im very certain I might have found the cause. I'm just not experienced enough in programming to make this change happen on my own.

Error Message: Configuration is valid! Ready! Checking ranks Set role by rank for { value: 'RTB#DMG', type: 'summonerName' } TypeError: Cannot read properties of undefined (reading 'includes') at Job.task (/home/container/src/events.js:96:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Issue: As stated in the Riot Developer Portal in this blog post - https://developer.riotgames.com/docs/summoner-name-to-riot-id-faq - Summoner Names in the API only contain old data as of November 20, 2023. This means players when they try to do /rank [ign] they need to use what they had before that date, if their account is older they are out of luck afaik.

Idea for a possible solution: Im certain we could implement the Riot API like this for everything to work with the new "Name#Tag" system.

Steps:

  1. Use provided gameName + tagLine from discord input and use the API endpoint /riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine} to retrieve the values puuid, gameName and tagLine. Use # as a seperator for formatting the input from the Discord user correctly.
  2. Store the puuid in our database alongside the gameName and tagLine.
  3. Get the id from response of this API endpoint: /lol/summoner/v4/summoners/by-puuid/{encryptedPUUID}
  4. Finally, like now, use the API endpoint /lol/league/v4/entries/by-summoner/{encryptedSummonerId} to retrieve the tier + rank values.

If I somehow can be of help or provide more details, please let me know. And thank you for making this discord bot! :)

simwai commented 5 months ago

Hey mate, you are right. This is really a problem.