From eddac5b8b2ad8df9df6f33a5315fed272ce2d800 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Tue, 15 Sep 2020 23:56:07 +0200 Subject: [PATCH] [ccrole] Specify an audit log reason --- ccrole/ccrole.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ccrole/ccrole.py b/ccrole/ccrole.py index 77a7fd3..eb654b1 100644 --- a/ccrole/ccrole.py +++ b/ccrole/ccrole.py @@ -7,6 +7,7 @@ from discord.ext.commands.view import StringView from redbot.core import Config, checks, commands from redbot.core.bot import Red from redbot.core.utils.chat_formatting import box, pagify +from redbot.core.utils.mod import get_audit_reason log = logging.getLogger("red.fox_v3.ccrole") @@ -358,12 +359,14 @@ class CCRole(commands.Cog): else: target = message.author + reason = get_audit_reason(message.author) + if cmd["aroles"]: arole_list = [ discord.utils.get(message.guild.roles, id=roleid) for roleid in cmd["aroles"] ] try: - await target.add_roles(*arole_list) + await target.add_roles(*arole_list, reason=reason) except discord.Forbidden: log.exception(f"Permission error: Unable to add roles") await ctx.send("Permission error: Unable to add roles") @@ -373,7 +376,7 @@ class CCRole(commands.Cog): discord.utils.get(message.guild.roles, id=roleid) for roleid in cmd["rroles"] ] try: - await target.remove_roles(*rrole_list) + await target.remove_roles(*rrole_list, reason=reason) except discord.Forbidden: log.exception(f"Permission error: Unable to remove roles") await ctx.send("Permission error: Unable to remove roles")