aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/halloweenify.py
diff options
context:
space:
mode:
authorGravatar JosuĂ© D. (JD) <[email protected]>2020-05-24 20:18:56 -0400
committerGravatar GitHub <[email protected]>2020-05-24 20:18:56 -0400
commit2defff0491ad15dcb692c3a60b74662378d472bd (patch)
tree346f8e57933423d086c66a512692f2615e101065 /bot/exts/halloween/halloweenify.py
parent5/24 - bot utils - added encoding, and notes for persist (diff)
parentMerge pull request #401 from fuzzmz/minesweeper-disabled-dm-handling (diff)
Merge branch 'master' into encoding_bug_fix
Diffstat (limited to 'bot/exts/halloween/halloweenify.py')
-rw-r--r--bot/exts/halloween/halloweenify.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/bot/exts/halloween/halloweenify.py b/bot/exts/halloween/halloweenify.py
index aae7590a..596c6682 100644
--- a/bot/exts/halloween/halloweenify.py
+++ b/bot/exts/halloween/halloweenify.py
@@ -4,6 +4,7 @@ from pathlib import Path
from random import choice
import discord
+from discord.errors import Forbidden
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
@@ -37,11 +38,25 @@ class Halloweenify(commands.Cog):
f"**{ctx.author.display_name}** wasn\'t spooky enough for you? That\'s understandable, "
f"{ctx.author.display_name} isn\'t scary at all! "
"Let me think of something better. Hmm... I got it!\n\n "
- f"Your new nickname will be: \n :ghost: **{nickname}** :jack_o_lantern:"
)
embed.set_image(url=image)
- await ctx.author.edit(nick=nickname)
+ if isinstance(ctx.author, discord.Member):
+ try:
+ await ctx.author.edit(nick=nickname)
+ embed.description += f"Your new nickname will be: \n:ghost: **{nickname}** :jack_o_lantern:"
+
+ except Forbidden: # The bot doesn't have enough permission
+ embed.description += (
+ f"Your new nickname should be: \n :ghost: **{nickname}** :jack_o_lantern: \n\n"
+ f"It looks like I cannot change your name, but feel free to change it yourself."
+ )
+
+ else: # The command has been invoked in DM
+ embed.description += (
+ f"Your new nickname should be: \n :ghost: **{nickname}** :jack_o_lantern: \n\n"
+ f"Feel free to change it yourself, or invoke the command again inside the server."
+ )
await ctx.send(embed=embed)