catch permissions errors when changing nicks
This commit is contained in:
parent
4b351648f7
commit
a1e086ba2f
|
@ -42,9 +42,12 @@ async def on_message(message):
|
||||||
if any(w in message.content for w in RUDE_WORDS):
|
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.')
|
await message.channel.send('Your Club Penguin account has been deactivated for inappropriate language.')
|
||||||
oldnick = message.author.nick
|
oldnick = message.author.nick
|
||||||
|
try:
|
||||||
await message.author.edit(nick="BANNED")
|
await message.author.edit(nick="BANNED")
|
||||||
await asyncio.sleep(300)
|
await asyncio.sleep(300)
|
||||||
await message.author.edit(nick=oldnick)
|
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:
|
with open('token') as f:
|
||||||
token = f.read().strip()
|
token = f.read().strip()
|
||||||
|
|
Loading…
Reference in a new issue