Return the original callback from commands' __call__ #92
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before if you did this:
It would raise an error because
_BaseCommand.__call__()returns the command instance itself, as opposed to the originaltestfunction. This would causeSayCommandto attempt to register theClientCommandinstance as a callback, which would fail.@Ayuto already hotfixed this here, but I believe that's just a workaround and doesn't solve the actual issue: the decorator is returned instead of the decorated function. Also, his workaround still doesn't allow one to call the
test()function after decorating it as a command. The following code wouldn't work becausetestis now aClientCommandinstance:Returning the command instance was necessary with the old
AutoUnloadclass which operated on global variables based on their name, but this update greatly improved the mechanism and returning the object is no longer required.