Skip to content

Commit

Permalink
multiple challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysquid committed Apr 25, 2024
1 parent abdae5f commit 8376652
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cogs/code_golf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ def challenge(argument: str) -> str:
return argument
else:
challenges = ", ".join(f"{dir.name}" for dir in sorted(CodeGolf.FILES_PATH.iterdir()) if dir.is_dir())
raise cmds.BadArgument(f"Invalid challenge name. Available challenges are: {challenges}" )
raise cmds.BadArgument(f"{argument} is not a valid challenge. Available challenges are: {challenges}" )

def challenges(arguments: str) -> str:
challenges = []
for argument in arguments.split(","):
if argument:
challenges.append(CodeGolf.challenge(argument))
return challenges

@golf.command(aliases=["ref"], hidden=True)
@cmds.has_role(ids.BUREAU)
Expand Down Expand Up @@ -161,14 +167,12 @@ def check(reaction: discord.Reaction, user: discord.User):

@golf.command(aliases=["sb"])
@cmds.guild_only()
async def scores(self, ctx: cmds.Context, challenge: challenge):
async def scores(self, ctx: cmds.Context, challenges: challenges):
"""
Display the scoreboard of a code golf challenge
"""

embed = discord.Embed(title=f"Code golf scoreboard :golf:")

challenges = [challenge] if challenge else [dir.name for dir in sorted(CodeGolf.FILES_PATH.iterdir()) if dir.is_dir()]

for challenge in challenges:
challenge_path = CodeGolf.FILES_PATH / challenge
Expand Down

0 comments on commit 8376652

Please sign in to comment.