Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Add error handling for ApplicationNotOwner exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavSys committed Mar 21, 2024
1 parent 00ef95e commit e4e7c8d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/exts/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nextcord.ext import commands
from nextcord.ext import commands, application_checks
import nextcord
from bot import Bot

Expand Down Expand Up @@ -31,16 +31,25 @@ async def on_application_command_error(
):
# Proper error handling will be added soon :)
error = getattr(error, "original", error)
embed = nextcord.Embed(
title="An Error Occurred",
description=f"An unexpected error occurred while processing your command. Please report it us.",
color=nextcord.Color.red(),
)
await interaction.send(embed=embed, ephemeral=True)
self.bot.logger.error(
f"An error occurred while processing an application command: {error}"
)
raise error
if isinstance(error, application_checks.errors.ApplicationNotOwner):
embed = nextcord.Embed(
title="An Error Occurred",
description="You must be the owner of this application to use this command.",
color=nextcord.Color.red(),
)
await interaction.send(embed=embed, ephemeral=True)
return
else:
embed = nextcord.Embed(
title="An Error Occurred",
description=f"An unexpected error occurred while processing your command. Please report it us.",
color=nextcord.Color.red(),
)
await interaction.send(embed=embed, ephemeral=True)
self.bot.logger.error(
f"An error occurred while processing an application command: {error}"
)
raise error


def setup(bot: Bot):
Expand Down

0 comments on commit e4e7c8d

Please sign in to comment.