[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>
This commit is contained in:
Dav 2020-02-14 15:13:44 +01:00 committed by GitHub
parent 6ddaff6260
commit e7969992c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,7 +198,7 @@ class Warnings(commands.Cog):
for r, v in registered_reasons.items(): for r, v in registered_reasons.items():
if await ctx.embed_requested(): if await ctx.embed_requested():
em = discord.Embed( 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"])) em.add_field(name=_("Points"), value=str(v["points"]))
msg_list.append(em) msg_list.append(em)
@ -226,7 +226,9 @@ class Warnings(commands.Cog):
if await ctx.embed_requested(): if await ctx.embed_requested():
em = discord.Embed(title=_("Action: {name}").format(name=r["action_name"])) 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=_("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) em.add_field(name=_("Drop command"), value=r["drop_command"], inline=False)
msg_list.append(em) msg_list.append(em)
else: else:
@ -371,7 +373,8 @@ class Warnings(commands.Cog):
description=user_warnings[key]["description"], description=user_warnings[key]["description"],
) )
await ctx.send_interactive( 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.command()
@ -400,13 +403,20 @@ class Warnings(commands.Cog):
description=user_warnings[key]["description"], description=user_warnings[key]["description"],
) )
await ctx.send_interactive( 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.command()
@commands.guild_only() @commands.guild_only()
@checks.admin_or_permissions(ban_members=True) @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.""" """Remove a warning from a user."""
guild = ctx.guild guild = ctx.guild
@ -440,7 +450,7 @@ class Warnings(commands.Cog):
"unwarned", "unwarned",
member, member,
ctx.message.author, ctx.message.author,
None, reason,
until=None, until=None,
channel=None, channel=None,
) )