2021-09-03 21:18:29 +02:00
|
|
|
from discord.ext import commands
|
2022-02-03 01:43:54 +01:00
|
|
|
from discord.commands import Option, SlashCommandGroup, ApplicationContext, permissions
|
|
|
|
from functions import config
|
2021-09-03 21:18:29 +02:00
|
|
|
from functions.football import get_matches, get_table, get_jpl_code
|
|
|
|
from startup.didier import Didier
|
|
|
|
|
|
|
|
|
|
|
|
class FootballSlash(commands.Cog):
|
|
|
|
def __init__(self, client: Didier):
|
|
|
|
self.client: Didier = client
|
|
|
|
|
2022-02-03 01:43:54 +01:00
|
|
|
_jpl_group = SlashCommandGroup("jpl", "Jupiler Pro League commands")
|
|
|
|
|
|
|
|
@_jpl_group.command(name="matches", description="Schema voor een bepaalde speeldag")
|
|
|
|
async def _jpl_matches_slash(self, ctx: ApplicationContext,
|
|
|
|
day: Option(int, name="day", description="Speeldag (default huidige)", required=False, default=None)
|
|
|
|
):
|
2021-09-03 21:18:29 +02:00
|
|
|
# Default is current day
|
|
|
|
if day is None:
|
|
|
|
day = int(config.get("jpl_day"))
|
|
|
|
|
2022-02-03 01:43:54 +01:00
|
|
|
await ctx.respond(get_matches(day))
|
2021-09-03 21:18:29 +02:00
|
|
|
|
2022-02-03 01:43:54 +01:00
|
|
|
@_jpl_group.command(name="table", description="Huidige rangschikking")
|
|
|
|
async def _jpl_table_slash(self, ctx: ApplicationContext):
|
2022-02-05 14:33:11 +01:00
|
|
|
await ctx.response.defer()
|
2022-02-03 01:43:54 +01:00
|
|
|
await ctx.respond(get_table())
|
2021-09-03 21:18:29 +02:00
|
|
|
|
2022-02-03 01:43:54 +01:00
|
|
|
@_jpl_group.command(name="update", description="Update de code voor deze competitie (owner-only)", default_permission=False)
|
|
|
|
@permissions.is_owner()
|
|
|
|
async def _jpl_update_slash(self, ctx: ApplicationContext):
|
2021-09-03 21:18:29 +02:00
|
|
|
code = get_jpl_code()
|
|
|
|
config.config("jpl", code)
|
2022-02-03 01:43:54 +01:00
|
|
|
await ctx.respond(f"Done (code: {code})")
|
2021-09-03 21:18:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
def setup(client: Didier):
|
|
|
|
client.add_cog(FootballSlash(client))
|