Summ level command finished
This commit is contained in:
parent
ae22fa98a6
commit
c6ecd46b24
8 changed files with 69 additions and 60 deletions
|
|
@ -2,6 +2,7 @@ from abc import abstractmethod, ABCMeta
|
|||
from datetime import datetime
|
||||
|
||||
import discord
|
||||
import requests
|
||||
import riotwatcher
|
||||
|
||||
|
||||
|
|
@ -11,12 +12,14 @@ class Command:
|
|||
pref = ""
|
||||
api: riotwatcher.LolWatcher
|
||||
commandName = ""
|
||||
region = ""
|
||||
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
|
||||
def __init__(self, pref, api: riotwatcher.LolWatcher, region: str, additionalKeywords: list):
|
||||
for i in additionalKeywords:
|
||||
self.keywords.append(i)
|
||||
self.pref = pref
|
||||
self.api = api
|
||||
self.region = region
|
||||
|
||||
@abstractmethod
|
||||
async def execute(self, message: discord.Message):
|
||||
|
|
@ -43,3 +46,23 @@ class Command:
|
|||
print(logMSG)
|
||||
with open("requests.log", "a") as f:
|
||||
f.write(logMSG)
|
||||
|
||||
def getSummonerNameFromMessage(self, message: discord.Message, argumentstart=1):
|
||||
ret = ""
|
||||
inp = message.content.split(" ")
|
||||
if len(inp) > argumentstart + 1:
|
||||
for i in inp[argumentstart:]:
|
||||
ret += " " + i
|
||||
|
||||
ret = ret[1:]
|
||||
else:
|
||||
ret = inp[argumentstart]
|
||||
return ret
|
||||
|
||||
async def checkSumname(self, sumname, message: discord.Message):
|
||||
try:
|
||||
var = self.api.summoner.by_name(self.region, sumname)["id"]
|
||||
return True
|
||||
except requests.exceptions.HTTPError:
|
||||
await message.channel.send("No matching player found with name **" + sumname + "**")
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue