update(commands:mute|Mod): add reason as optional

This commit is contained in:
Romain J 2021-05-17 00:20:56 +02:00
parent 7b50af0207
commit f06bfd7e24
2 changed files with 13 additions and 9 deletions

View file

@ -57,6 +57,9 @@ class BotMessageConverter(commands.Converter):
class ReasonConverter(commands.Converter):
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
if argument is None:
return f"{ctx.author.display_name} (ID: {ctx.author.id})"
if len(argument) > 300:
raise ReasonTooLongException(
_("Reason length must be 300 characters or lower.")

View file

@ -1,5 +1,6 @@
import logging
from datetime import datetime
from typing import Optional
import discord
from discord.ext import commands
@ -281,7 +282,7 @@ class Mod(commands.Cog):
ctx: ContextPlus,
members: commands.Greedy[discord.Member],
*,
reason: ReasonConverter,
reason: Optional[ReasonConverter],
):
if not members:
return await ctx.send(_("Missing members", ctx, self.bot.config))
@ -360,9 +361,9 @@ class Mod(commands.Cog):
time,
members: discord.Member,
*,
reason: ReasonConverter,
reason: Optional[ReasonConverter],
):
...
_, _, _, _ = ctx, time, members, reason
# =========================================================================
@ -377,7 +378,7 @@ class Mod(commands.Cog):
ctx: ContextPlus,
members: commands.Greedy[discord.Member],
*,
reason: ReasonConverter,
reason: Optional[ReasonConverter],
):
if not members:
return await ctx.send(_("Missing members", ctx, self.bot.config))