2020-10-13 21:02:40 +02:00
|
|
|
from decorators import help
|
|
|
|
from discord.ext import commands
|
|
|
|
from enums.help_categories import Category
|
|
|
|
from functions import checks, config
|
2021-08-19 20:35:22 +02:00
|
|
|
from functions.football import getMatches, getTable, get_jpl_code
|
2020-10-13 21:02:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Football(commands.Cog):
|
|
|
|
def __init__(self, client):
|
|
|
|
self.client = client
|
|
|
|
|
|
|
|
# Don't allow any commands to work when locked
|
|
|
|
def cog_check(self, ctx):
|
2021-01-26 21:59:22 +01:00
|
|
|
return not self.client.locked
|
2020-10-13 21:02:40 +02:00
|
|
|
|
|
|
|
@commands.group(name="Jpl", case_insensitive=True, invoke_without_command=True)
|
|
|
|
@commands.check(checks.allowedChannels)
|
|
|
|
@help.Category(Category.Sports)
|
|
|
|
async def jpl(self, ctx, *args):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@jpl.command(name="Matches", aliases=["M"], usage="[Week]*")
|
|
|
|
async def matches(self, ctx, *args):
|
|
|
|
args = list(args)
|
2021-01-25 00:16:38 +01:00
|
|
|
|
|
|
|
# Default is current day
|
2020-10-13 21:02:40 +02:00
|
|
|
if not args:
|
|
|
|
args = [str(config.get("jpl_day"))]
|
|
|
|
|
2021-01-25 00:16:38 +01:00
|
|
|
if all(letter.isdigit() for letter in args[0]):
|
|
|
|
await ctx.send(getMatches(int(args[0])))
|
2020-10-13 21:02:40 +02:00
|
|
|
else:
|
|
|
|
return await ctx.send("Dit is geen geldige speeldag.")
|
|
|
|
|
|
|
|
@jpl.command(name="Table", aliases=["Ranking", "Rankings", "Ranks", "T"])
|
|
|
|
async def table(self, ctx, *args):
|
2021-01-26 21:58:49 +01:00
|
|
|
await ctx.send(getTable())
|
2020-10-13 21:02:40 +02:00
|
|
|
|
2021-08-19 20:35:22 +02:00
|
|
|
@commands.check(checks.isMe)
|
|
|
|
@jpl.command(name="Update")
|
|
|
|
async def update(self, ctx):
|
|
|
|
code = get_jpl_code()
|
|
|
|
config.config("jpl", code)
|
|
|
|
await ctx.message.add_reaction("✅")
|
|
|
|
|
2020-10-13 21:02:40 +02:00
|
|
|
|
|
|
|
def setup(client):
|
|
|
|
client.add_cog(Football(client))
|