Skip to content

Commit 927d0e7

Browse files
authored
Merge pull request #81 from kkrypt0nn/fix/exception-when-exception-in-dms
2 parents d530c17 + 0083088 commit 927d0e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ async def on_command_error(context: Context, error) -> None:
224224
color=0xE02B2B
225225
)
226226
await context.send(embed=embed)
227-
bot.logger.warning(
228-
f"{context.author} (ID: {context.author.id}) tried to execute a command in the guild {context.guild.name} (ID: {context.guild.id}), but the user is blacklisted from using the bot.")
227+
if context.guild:
228+
bot.logger.warning(f"{context.author} (ID: {context.author.id}) tried to execute a command in the guild {context.guild.name} (ID: {context.guild.id}), but the user is blacklisted from using the bot.")
229+
else:
230+
bot.logger.warning(f"{context.author} (ID: {context.author.id}) tried to execute a command in the bot's DMs, but the user is blacklisted from using the bot.")
229231
elif isinstance(error, exceptions.UserNotOwner):
230232
"""
231233
Same as above, just for the @checks.is_owner() check.
@@ -235,8 +237,12 @@ async def on_command_error(context: Context, error) -> None:
235237
color=0xE02B2B
236238
)
237239
await context.send(embed=embed)
238-
bot.logger.warning(
240+
if context.guild:
241+
bot.logger.warning(
239242
f"{context.author} (ID: {context.author.id}) tried to execute an owner only command in the guild {context.guild.name} (ID: {context.guild.id}), but the user is not an owner of the bot.")
243+
else:
244+
bot.logger.warning(
245+
f"{context.author} (ID: {context.author.id}) tried to execute an owner only command in the bot's DMs, but the user is not an owner of the bot.")
240246
elif isinstance(error, commands.MissingPermissions):
241247
embed = discord.Embed(
242248
description="You are missing the permission(s) `" + ", ".join(

0 commit comments

Comments
 (0)