Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors from interactions are not handled by the Errors cog #213

Open
ZRunner opened this issue Jun 10, 2023 · 1 comment
Open

Errors from interactions are not handled by the Errors cog #213

ZRunner opened this issue Jun 10, 2023 · 1 comment
Labels
bug Something isn't working enhancement Request enhancement of an existing feature

Comments

@ZRunner
Copy link
Contributor

ZRunner commented Jun 10, 2023

Discord.py added a long time ago a new on_interaction_error event handler, specifically made to handle errors from app commands, buttons, modals, autocompletion etc.

This handled has not been added to our Error cog, so these errors are only printed into the bot console and will never show in our error channel for example.

Check https://github.com/ZRunner/Axobot/blob/ccdbb05d59cc0b688080e7f6c3ef944fda459888/fcts/errors.py#L233 for an example of implementation (could be done better)

@ZRunner ZRunner added bug Something isn't working enhancement Request enhancement of an existing feature labels Jun 10, 2023
@ZRunner
Copy link
Contributor Author

ZRunner commented Jun 10, 2023

EDIT: my bad, the on_interaction_error is not a native d.py event but one I had to create myself for the needs of my bot, sorry for the confusion.

Here is how I did it:

  • the Client.tree attribute has an on_error method called "when any command raises an AppCommandError" (from the d.py doc)
  • I overwrote this method by my own method, which basically calls the event dispatcher with an unique event: self.dispatch("interaction_error", interaction, error)
  • I then added an event listener in the Error cog, listening to this unique event (the one I linked in my first comment)

I believe this is the best way to do things and will allow us to more easily catch interaction-related errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Request enhancement of an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant