From a1e086ba2f6cab59ce1f4bda3c557c504bd011a8 Mon Sep 17 00:00:00 2001 From: xenofem Date: Fri, 15 May 2020 22:41:43 -0400 Subject: [PATCH] catch permissions errors when changing nicks --- club-penguin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/club-penguin.py b/club-penguin.py index 5566a42..0cf30f2 100644 --- a/club-penguin.py +++ b/club-penguin.py @@ -42,9 +42,12 @@ async def on_message(message): if any(w in message.content for w in RUDE_WORDS): await message.channel.send('Your Club Penguin account has been deactivated for inappropriate language.') oldnick = message.author.nick - await message.author.edit(nick="BANNED") - await asyncio.sleep(300) - await message.author.edit(nick=oldnick) + try: + await message.author.edit(nick="BANNED") + await asyncio.sleep(300) + await message.author.edit(nick=oldnick) + except discord.Forbidden: + print('Permissions error while trying to change nickname of {}'.format(message.author), file=sys.stderr) with open('token') as f: token = f.read().strip()