From 2a396b44385330d19fe651e78a89b5c7c9724b6f Mon Sep 17 00:00:00 2001 From: El Laggron Date: Sat, 11 Aug 2018 03:44:17 +0200 Subject: [PATCH] [Modlog] Make the case number optional in [p]reason (#1979) * [V3 Modlog] Make the case number optional If not specified, it will be the latest case. * Fix some errors * Black reformat * More info for usage string * Use isdigit instead of isnumeric --- redbot/cogs/modlog/modlog.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/redbot/cogs/modlog/modlog.py b/redbot/cogs/modlog/modlog.py index a79f9656d..34e72991d 100644 --- a/redbot/cogs/modlog/modlog.py +++ b/redbot/cogs/modlog/modlog.py @@ -97,17 +97,24 @@ class ModLog: else: await ctx.send(embed=await case.get_case_msg_content()) - @commands.command() + @commands.command(usage="[case] ") @commands.guild_only() - async def reason(self, ctx: commands.Context, case: int, *, reason: str = ""): + async def reason(self, ctx: commands.Context, *, reason: str): """Lets you specify a reason for mod-log's cases + Please note that you can only edit cases you are - the owner of unless you are a mod/admin or the server owner""" + the owner of unless you are a mod/admin or the server owner. + + If no number is specified, the latest case will be used.""" author = ctx.author guild = ctx.guild - if not reason: - await ctx.send_help() - return + potential_case = reason.split()[0] + if potential_case.isdigit(): + case = int(potential_case) + reason = reason.replace(potential_case, "") + else: + case = str(int(await modlog.get_next_case_number(guild)) - 1) + # latest case try: case_before = await modlog.get_case(case, guild, self.bot) except RuntimeError: