Repository: Cog-Creators/Red-DiscordBot

Issue:
`[p]unwarn` has no arg for reason, and modlog says one is addable
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

`[p]unwarn`

#### What cog is this command from?

`warnings`

#### What were you expecting to happen?

There to be a third argument where you can put an optional reason for unwarning the user.

#### What actually happened?

There is no argument that allows you to set the reason. The modlog channel says "**Reason:** Use the `reason` command to add it", implying that you should be able to set a reason without needing to do it in two commands.

#### How can we reproduce this issue?

1. `[p]load warnings`
2. Set up a modlog channel, `[p]modlogset modlog <channel>`
3. `[p]warn` someone
4. `[p]unwarn` them, and note how you cannot add a reason
5. Notice how the modlog says that there is no reason added to the case
6. Use `[p]reason` and notice how you can add a warning to the case

#### Others
I may (attempt!) to PR a fix myself - though I'm a little busy so feel free to do this yourself.
I would like to thank [Skyrider#1337 for reporting this bug](https://discordapp.com/channels/133049272517001216/387398816317440000/639794017596473355). And yes, I waited a whole 11.5 hours for them to open an issue themselves.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/warnings/warnings.py b/redbot/cogs/warnings/warnings.py
--- a/redbot/cogs/warnings/warnings.py
+++ b/redbot/cogs/warnings/warnings.py
@@ -198,7 +198,7 @@ async def reasonlist(self, ctx: commands.Context):
             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 @@ async def actionlist(self, ctx: commands.Context):
                 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 @@ async def warnings(self, ctx: commands.Context, user: Union[discord.Member, int]
                         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 @@ async def mywarnings(self, ctx: commands.Context):
                         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 @@ async def unwarn(self, ctx: commands.Context, user: Union[discord.Member, int],
                 "unwarned",
                 member,
                 ctx.message.author,
-                None,
+                reason,
                 until=None,
                 channel=None,
             )


Test patch: