iLeague_Bot/APICommands/F2PCommand.py
2022-03-21 02:43:00 +01:00

57 lines
2.2 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from abc import ABC
import discord
import riotwatcher
import APICommands.Command
from APICommands.Command import getSummonerNameFromMessage, getChampionsJSON, championIdToName
class Free2Play(APICommands.Command.Command, ABC):
commandName = "Free 2 Play"
keywords = ["f2p", "rotation", "F2P", "ROTATION"]
def __init__(self, pref, api: riotwatcher.LolWatcher, region: str, additionalKeywords=None):
if additionalKeywords is None:
additionalKeywords = []
super().__init__(pref, api, region, additionalKeywords)
async def execute(self, message: discord.Message):
sumname = ""
output = "Derzeitige F2P Champions"
rot = self.api.champion.rotations(self.region)["freeChampionIds"]
championsJSON = getChampionsJSON()
try:
sumname = getSummonerNameFromMessage(message, 1)
except:
await self.usage(message)
if sumname != "":
if not await self.checkSumname(sumname, message):
return
output += " auf denen **" + sumname + "** noch keine Punkte hast: \n"
response = self.api.champion_mastery.by_summoner(self.region,
self.api.summoner.by_name(self.region,
sumname)["id"])
allIds = []
for i in response:
allIds.append(i["championId"])
for i in rot:
if i not in allIds:
output += ("\t- **" + championIdToName(i, championsJSON) + "**\n")
else:
output += ":\n"
for i in rot:
output += ("\t- **" + championIdToName(i, championsJSON) + "**\n")
await message.channel.send(output)
if len(output.split("\n")) <= 2:
await message.channel.send("\t- **Keine**")
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 + "f2p [Summoner ("
"optional)]")