mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[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
This commit is contained in:
parent
51a54863c5
commit
2a396b4438
@ -97,17 +97,24 @@ class ModLog:
|
|||||||
else:
|
else:
|
||||||
await ctx.send(embed=await case.get_case_msg_content())
|
await ctx.send(embed=await case.get_case_msg_content())
|
||||||
|
|
||||||
@commands.command()
|
@commands.command(usage="[case] <reason>")
|
||||||
@commands.guild_only()
|
@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
|
"""Lets you specify a reason for mod-log's cases
|
||||||
|
|
||||||
Please note that you can only edit cases you are
|
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
|
author = ctx.author
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
if not reason:
|
potential_case = reason.split()[0]
|
||||||
await ctx.send_help()
|
if potential_case.isdigit():
|
||||||
return
|
case = int(potential_case)
|
||||||
|
reason = reason.replace(potential_case, "")
|
||||||
|
else:
|
||||||
|
case = str(int(await modlog.get_next_case_number(guild)) - 1)
|
||||||
|
# latest case
|
||||||
try:
|
try:
|
||||||
case_before = await modlog.get_case(case, guild, self.bot)
|
case_before = await modlog.get_case(case, guild, self.bot)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user