mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Add football slash commands, clean up some ugly stuff
This commit is contained in:
parent
0ec321a51b
commit
2e51af6f1c
4 changed files with 66 additions and 31 deletions
|
|
@ -2,7 +2,7 @@ from decorators import help
|
|||
from discord.ext import commands
|
||||
from enums.help_categories import Category
|
||||
from functions import checks, config
|
||||
from functions.football import getMatches, getTable, get_jpl_code
|
||||
from functions.football import get_matches, get_table, get_jpl_code
|
||||
|
||||
|
||||
class Football(commands.Cog):
|
||||
|
|
@ -20,21 +20,16 @@ class Football(commands.Cog):
|
|||
pass
|
||||
|
||||
@jpl.command(name="Matches", aliases=["M"], usage="[Week]*")
|
||||
async def matches(self, ctx, *args):
|
||||
args = list(args)
|
||||
|
||||
async def matches(self, ctx, day: int = None):
|
||||
# Default is current day
|
||||
if not args:
|
||||
args = [str(config.get("jpl_day"))]
|
||||
if day is None:
|
||||
day = int(config.get("jpl_day"))
|
||||
|
||||
if all(letter.isdigit() for letter in args[0]):
|
||||
await ctx.send(getMatches(int(args[0])))
|
||||
else:
|
||||
return await ctx.send("Dit is geen geldige speeldag.")
|
||||
await ctx.send(get_matches(day))
|
||||
|
||||
@jpl.command(name="Table", aliases=["Ranking", "Rankings", "Ranks", "T"])
|
||||
async def table(self, ctx, *args):
|
||||
await ctx.send(getTable())
|
||||
async def table(self, ctx):
|
||||
await ctx.send(get_table())
|
||||
|
||||
@commands.check(checks.isMe)
|
||||
@jpl.command(name="Update")
|
||||
|
|
|
|||
44
cogs/slash/football_slash.py
Normal file
44
cogs/slash/football_slash.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from discord.ext import commands
|
||||
from dislash import SlashInteraction, slash_command, Option, OptionType
|
||||
from functions import config, checks
|
||||
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
|
||||
|
||||
@slash_command(name="jpl", description="Jupiler Pro League commands")
|
||||
async def _jpl_group(self, interaction: SlashInteraction):
|
||||
pass
|
||||
|
||||
@_jpl_group.sub_command(name="matches",
|
||||
description="Schema voor een bepaalde speeldag",
|
||||
options=[
|
||||
Option("day", "Speeldag (default huidige)", OptionType.INTEGER)
|
||||
]
|
||||
)
|
||||
async def _jpl_matches_slash(self, interaction: SlashInteraction, day: int = None):
|
||||
# Default is current day
|
||||
if day is None:
|
||||
day = int(config.get("jpl_day"))
|
||||
|
||||
await interaction.reply(get_matches(day))
|
||||
|
||||
@_jpl_group.sub_command(name="table", description="Huidige rangschikking")
|
||||
async def _jpl_table_slash(self, interaction: SlashInteraction):
|
||||
await interaction.reply(get_table())
|
||||
|
||||
@_jpl_group.sub_command(name="update", description="Update de code voor deze competitie (owner-only)")
|
||||
async def _jpl_update_slash(self, interaction: SlashInteraction):
|
||||
if not await checks.isMe(interaction):
|
||||
return await interaction.reply(f"Je hebt geen toegang tot dit commando.")
|
||||
|
||||
code = get_jpl_code()
|
||||
config.config("jpl", code)
|
||||
await interaction.reply(f"Done (code: {code})")
|
||||
|
||||
|
||||
def setup(client: Didier):
|
||||
client.add_cog(FootballSlash(client))
|
||||
Loading…
Add table
Add a link
Reference in a new issue