update(commands:mute|Mod): add reason as optional
This commit is contained in:
parent
7b50af0207
commit
f06bfd7e24
2 changed files with 13 additions and 9 deletions
|
@ -57,6 +57,9 @@ class BotMessageConverter(commands.Converter):
|
||||||
|
|
||||||
class ReasonConverter(commands.Converter):
|
class ReasonConverter(commands.Converter):
|
||||||
async def convert(self, ctx: Context, argument: str): # skipcq: PYL-W0613
|
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:
|
if len(argument) > 300:
|
||||||
raise ReasonTooLongException(
|
raise ReasonTooLongException(
|
||||||
_("Reason length must be 300 characters or lower.")
|
_("Reason length must be 300 characters or lower.")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -281,7 +282,7 @@ class Mod(commands.Cog):
|
||||||
ctx: ContextPlus,
|
ctx: ContextPlus,
|
||||||
members: commands.Greedy[discord.Member],
|
members: commands.Greedy[discord.Member],
|
||||||
*,
|
*,
|
||||||
reason: ReasonConverter,
|
reason: Optional[ReasonConverter],
|
||||||
):
|
):
|
||||||
if not members:
|
if not members:
|
||||||
return await ctx.send(_("Missing members", ctx, self.bot.config))
|
return await ctx.send(_("Missing members", ctx, self.bot.config))
|
||||||
|
@ -360,9 +361,9 @@ class Mod(commands.Cog):
|
||||||
time,
|
time,
|
||||||
members: discord.Member,
|
members: discord.Member,
|
||||||
*,
|
*,
|
||||||
reason: ReasonConverter,
|
reason: Optional[ReasonConverter],
|
||||||
):
|
):
|
||||||
...
|
_, _, _, _ = ctx, time, members, reason
|
||||||
|
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
|
@ -377,7 +378,7 @@ class Mod(commands.Cog):
|
||||||
ctx: ContextPlus,
|
ctx: ContextPlus,
|
||||||
members: commands.Greedy[discord.Member],
|
members: commands.Greedy[discord.Member],
|
||||||
*,
|
*,
|
||||||
reason: ReasonConverter,
|
reason: Optional[ReasonConverter],
|
||||||
):
|
):
|
||||||
if not members:
|
if not members:
|
||||||
return await ctx.send(_("Missing members", ctx, self.bot.config))
|
return await ctx.send(_("Missing members", ctx, self.bot.config))
|
||||||
|
|
Loading…
Reference in a new issue