From 3d4c0ecacf6aae1b2159eb68aeb3d5cdf0dd675e Mon Sep 17 00:00:00 2001 From: Ave Date: Mon, 25 May 2020 14:06:29 +0300 Subject: [PATCH] mod/nickname: Handle permission issues I vape --- cogs/mod.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cogs/mod.py b/cogs/mod.py index e6da20b..9edc236 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -481,12 +481,18 @@ class Mod(Cog): Just send .nickname to wipe the nickname.""" - if nick: - await target.edit(nick=nick, reason=str(ctx.author)) - else: - await target.edit(nick=None, reason=str(ctx.author)) + try: + if nick: + await target.edit(nick=nick, reason=str(ctx.author)) + else: + await target.edit(nick=None, reason=str(ctx.author)) - await ctx.send("Successfully set nickname.") + await ctx.send("Successfully set nickname.") + except discord.errors.Forbidden: + await ctx.send( + "I don't have the permission to set that user's nickname.\n" + "User's top role may be above mine, or I may lack Manage Nicknames permission." + ) @commands.guild_only() @commands.check(check_if_staff)