You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature should allow developers to be able to easily create custom error handling via external files, in a similar way that they can create custom help commands
What is the feature request for?
nextcord.ext.commands
The Problem
The issue this feature is designed to tackle, is that there is yet to be an easy and dynamic way of tackling error handling in external files. In my help thread (https://discord.com/channels/881118111967883295/1110347020666941500) I attempted to tackle the creation of error handling using cogs, however, soon ran into the issue that listeners do not override the default callback from the Nextcord library (as pointed out in Ethan's first message).
The main issue, is that it is not possible to create error handling in external files dynamically. More specifically, the only solution there is to creating events in external files for error handling, is by manually overriding each and every error event from nextcord.ext.commands.Bot. This issue does, however, not only apply to the error events, but also the other events such as the on_ready event (assuming you would want to override that method and have it run in an alternate file.
The Ideal Solution
Ideally, it would be cool to have 1 or 2 Nextcord classes that could be subclassed, like we can with custom Helpcommands using nextcord.ext.commands.HelpCommand classes. These developer created subclasses would then be passed to nextcord.ext.commands.Bot as an argument.
At bare minimum, I would hope to have 1 class, which solely tackles the following error events:
The error handling methods in the nextcord.ext.commands.ErrorHanlder subclass are to be named after the event they are supposed to be replacing. My thought would be, that if a developer doesn't create their own error handling for one of more of these events, but passes their subclass to their bot instance, then the parent class (nextcord.ext.commands.ErrorHandler) would have it's own "fancy" error handling (just something simple like sending an embed message to discord with the error/traceback or something) which developers could use. This would probably want to be toggleable though.
Regarding my original statement:
it would be cool to have 1 or 2 Nextcord classes
I was thinking, that this could potentially even be applied to further nextcord events. For example:
1 class purely for error handling, then maybe
A 2nd class for all nextcord events (if an event is not created/overriden in the subclass, it would just call the default nextcord method)
Perhaps further groups such as guild events (covering events such as creating/editing/deleting channels, thread events, etc etc)? - This does, however, branch out of the purpose of this issue though. This issue is supposed to solely focus on easy error handling creation (and perhaps even offer a template error handler if people are lazy)
Example of using this Nextcord error handler, if they didn't want to make their own:
The current solution is to override the nextcord.ext.commands.Bot event attributes. I personally do it in the init duner method of my ErrorHandler class as I feel like that is the best version, however there are other ways (example 2):
I personally feel that adding this suggestion would make working with Nextcord easier, in particular when it comes to creating error handlers and maintaining decent code architecture in the process. Additionally, I think it would be nice if Nextcord offered a simple error handler people could use, if they didn't want to make their own :)
The text was updated successfully, but these errors were encountered:
Gangsta-Muffin
changed the title
Feat: Easier Nextcord error handling
Feat: Better error handling ( Nextcord provided handlers)
May 25, 2023
ooliver1
changed the title
Feat: Better error handling ( Nextcord provided handlers)
Better error handling ( Nextcord provided handlers)
Jun 14, 2023
Summary
This feature should allow developers to be able to easily create custom error handling via external files, in a similar way that they can create custom help commands
What is the feature request for?
nextcord.ext.commands
The Problem
The issue this feature is designed to tackle, is that there is yet to be an easy and dynamic way of tackling error handling in external files. In my help thread (https://discord.com/channels/881118111967883295/1110347020666941500) I attempted to tackle the creation of error handling using cogs, however, soon ran into the issue that listeners do not override the default callback from the Nextcord library (as pointed out in Ethan's first message).
The main issue, is that it is not possible to create error handling in external files dynamically. More specifically, the only solution there is to creating events in external files for error handling, is by manually overriding each and every error event from
nextcord.ext.commands.Bot
. This issue does, however, not only apply to the error events, but also the other events such as theon_ready
event (assuming you would want to override that method and have it run in an alternate file.The Ideal Solution
Ideally, it would be cool to have 1 or 2 Nextcord classes that could be subclassed, like we can with custom Helpcommands using
nextcord.ext.commands.HelpCommand
classes. These developer created subclasses would then be passed tonextcord.ext.commands.Bot
as an argument.At bare minimum, I would hope to have 1 class, which solely tackles the following error events:
Here is how I imagine the class would get used:
The error handling methods in the
nextcord.ext.commands.ErrorHanlder
subclass are to be named after the event they are supposed to be replacing. My thought would be, that if a developer doesn't create their own error handling for one of more of these events, but passes their subclass to their bot instance, then the parent class (nextcord.ext.commands.ErrorHandler
) would have it's own "fancy" error handling (just something simple like sending an embed message to discord with the error/traceback or something) which developers could use. This would probably want to be toggleable though.Regarding my original statement:
I was thinking, that this could potentially even be applied to further nextcord events. For example:
Example of using this Nextcord error handler, if they didn't want to make their own:
The Current Solution
The current solution is to override the
nextcord.ext.commands.Bot
event attributes. I personally do it in the init duner method of my ErrorHandler class as I feel like that is the best version, however there are other ways (example 2):Example 2 (a worse solution imo:
Additional Context
I personally feel that adding this suggestion would make working with Nextcord easier, in particular when it comes to creating error handlers and maintaining decent code architecture in the process. Additionally, I think it would be nice if Nextcord offered a simple error handler people could use, if they didn't want to make their own :)
The text was updated successfully, but these errors were encountered: