mod/nickname: Handle permission issues

I vape
This commit is contained in:
Ave 2020-05-25 14:06:29 +03:00
parent 341e7e61c9
commit 3d4c0ecacf
No known key found for this signature in database
GPG key ID: 398DD7BD03276F6D

View file

@ -481,12 +481,18 @@ class Mod(Cog):
Just send .nickname <user> 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)