HighestMasteryCommand.py done done done done done

This commit is contained in:
s-prechtl 2022-03-17 14:24:49 +01:00
parent 58fa6e0823
commit 36a8795245

View file

@ -28,37 +28,34 @@ class HighestMastery(APICommands.Command.Command, ABC):
return
listlen = int(message.content.split(" ")[1]) if firstIsInt else 10
try:
output = getChampionMasteryList(sumname, listlen)
output = self.getChampionMasteryList(sumname, listlen)
for i in output:
await message.channel.send(i)
except:
await self.usage(message)
async def info(self, message: discord.Message):
pass
async def info(self, message: discord.Message):
pass
async def usage(self, message: discord.Message):
await message.channel.send("Wrong usage of" + self.commandName + "!\nUsage: " + self.pref + "hm [count] ["
"Summonername]")
async def usage(self, message: discord.Message):
await message.channel.send("Wrong usage of" + self.commandName + "!\nUsage: " + self.pref + "hm [count] ["
"Summonername]")
def getChampionMasteryList(sumname, listlen):
output = ["Der Spieler " + sumname + " hat den höchsten Mastery auf diesen " + str(
listlen) + " Champions\n"]
count = 0
response = self.api.champion_mastery.by_summoner(self.region, self.getEncryptedSummonerID(sumname))[
:listlen]
championsJSON = getChampionsJSON()
for i in response:
champname = championIdToName(i["championId"], championsJSON)
mpoints = i["championPoints"]
mastery = i["championLevel"]
out = "**" + champname + "**" + " Points: " + str(mpoints) + " Level: " + str(
mastery) + "\n"
if len(output[count]) + len(out) >= 2000:
output.append("")
count += 1
output[count] += out
return output
def getChampionMasteryList(self, sumname, listlen):
output = ["Der Spieler " + sumname + " hat den höchsten Mastery auf diesen " + str(
listlen) + " Champions\n"]
count = 0
response = self.api.champion_mastery.by_summoner(self.region, self.getEncryptedSummonerID(sumname))[
:listlen]
championsJSON = getChampionsJSON()
for i in response:
champname = championIdToName(i["championId"], championsJSON)
mpoints = i["championPoints"]
mastery = i["championLevel"]
out = "**" + champname + "**" + " Points: " + str(mpoints) + " Level: " + str(
mastery) + "\n"
if len(output[count]) + len(out) >= 2000:
output.append("")
count += 1
output[count] += out
return output