From e7969992c3cffc708091f23ef3a55f68b3f8f053 Mon Sep 17 00:00:00 2001 From: Dav <57032623+Dav-Git@users.noreply.github.com> Date: Fri, 14 Feb 2020 15:13:44 +0100 Subject: [PATCH] [Warnings]Make it possible to add reason with unwarn (#3490) * Unwarn now able to have a reason * black * Update string to say Run instead of Do Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com> * Make error for unregistered reason less agressive Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com> * Removing unneccessary lines and not putting the user input through the translator. * Because black hates me, here black formatting with adjusted line length * Trigger CI * Now always sendes a message when an invalid reason is passed, not only if the command author was an admin, guild owner or bot owner. * That should do the trick * Correct * Make Reason optional Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com> Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/warnings/warnings.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/redbot/cogs/warnings/warnings.py b/redbot/cogs/warnings/warnings.py index 458f43ff9..276074700 100644 --- a/redbot/cogs/warnings/warnings.py +++ b/redbot/cogs/warnings/warnings.py @@ -198,7 +198,7 @@ class Warnings(commands.Cog): for r, v in registered_reasons.items(): if await ctx.embed_requested(): em = discord.Embed( - title=_("Reason: {name}").format(name=r), description=v["description"] + title=_("Reason: {name}").format(name=r), description=v["description"], ) em.add_field(name=_("Points"), value=str(v["points"])) msg_list.append(em) @@ -226,7 +226,9 @@ class Warnings(commands.Cog): if await ctx.embed_requested(): em = discord.Embed(title=_("Action: {name}").format(name=r["action_name"])) em.add_field(name=_("Points"), value="{}".format(r["points"]), inline=False) - em.add_field(name=_("Exceed command"), value=r["exceed_command"], inline=False) + em.add_field( + name=_("Exceed command"), value=r["exceed_command"], inline=False, + ) em.add_field(name=_("Drop command"), value=r["drop_command"], inline=False) msg_list.append(em) else: @@ -371,7 +373,8 @@ class Warnings(commands.Cog): description=user_warnings[key]["description"], ) await ctx.send_interactive( - pagify(msg, shorten_by=58), box_lang=_("Warnings for {user}").format(user=user) + pagify(msg, shorten_by=58), + box_lang=_("Warnings for {user}").format(user=user), ) @commands.command() @@ -400,13 +403,20 @@ class Warnings(commands.Cog): description=user_warnings[key]["description"], ) await ctx.send_interactive( - pagify(msg, shorten_by=58), box_lang=_("Warnings for {user}").format(user=user) + pagify(msg, shorten_by=58), + box_lang=_("Warnings for {user}").format(user=user), ) @commands.command() @commands.guild_only() @checks.admin_or_permissions(ban_members=True) - async def unwarn(self, ctx: commands.Context, user: Union[discord.Member, int], warn_id: str): + async def unwarn( + self, + ctx: commands.Context, + user: Union[discord.Member, int], + warn_id: str, + reason: str = None, + ): """Remove a warning from a user.""" guild = ctx.guild @@ -440,7 +450,7 @@ class Warnings(commands.Cog): "unwarned", member, ctx.message.author, - None, + reason, until=None, channel=None, )