didier/cogs/slash/football_slash.py

38 lines
1.5 KiB
Python
Raw Normal View History

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
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)
):
# 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))
2022-02-03 01:43:54 +01:00
@_jpl_group.command(name="table", description="Huidige rangschikking")
async def _jpl_table_slash(self, ctx: ApplicationContext):
await ctx.respond(get_table())
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):
code = get_jpl_code()
config.config("jpl", code)
2022-02-03 01:43:54 +01:00
await ctx.respond(f"Done (code: {code})")
def setup(client: Didier):
client.add_cog(FootballSlash(client))