33 Commits

Author SHA1 Message Date
Rapptz
1b2c527fc7 [commands] Fix logic in Cog.has_error_handler() 2021-04-05 21:08:54 -04:00
Rapptz
4aee7fed5d [commands] Only remove top level commands on cog load failure 2021-03-28 18:35:59 -04:00
Nadir Chowdhury
63ec23bac2
Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
Rapptz
b9a99238e8 [commands] Add Command/Cog.has_error_handler
This allows querying the state without relying on internal undocumented
attributes.
2021-01-15 06:00:45 -05:00
Nihaal Sangha
69bdc3a184
Change copyright year to present 2021-01-15 05:28:11 -05:00
Rapptz
6ea7fce828 [commands] Cog unload failures are swallowed.
Fix #6113
2020-12-03 19:17:28 -05:00
SebbyLaw
4adbe03d7c [commands] Allow setting description of cogs 2020-11-26 01:57:24 -05:00
Michael
93fa46713a
Fix and add documentation 2020-09-23 03:19:35 -04:00
Dan Hess
7acec502a6
[commands] Correct command removing during cog injecting 2020-09-09 19:48:00 -04:00
Jaime Garcia Jr
1c3b0c02f8 Add revisions to check_once docs 2020-07-24 09:18:42 -05:00
Jaime Garcia Jr
5813593d6e Add documentation on bot_check_once 2020-07-23 12:19:10 -05:00
Sebastian Law
b4b953bfc6
Fix various inconsistencies within the documentation (#5067) 2020-06-28 03:45:58 -04:00
Xua
4e6942194f [commands] Document that cog_command_error must be async 2020-05-10 16:48:59 -04:00
Rapptz
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
NCPlayz
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
Rapptz
919dbcafb3 Consistent use of __all__ to prevent merge conflicts. 2019-04-20 17:20:58 -04:00
Rapptz
743a5a218f [commands] Disallow bot_ or cog_ commands or listeners in cogs. 2019-04-06 19:46:22 -04:00
NCPlayz
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
Rapptz
f43690bde8 [commands] Walk through MRO for Cog derived classes.
This should support cog subclasses in a relatively consistent way in
terms of expectations. Hopefully nothing is broken.

Fixes #1950
2019-03-17 22:04:05 -04:00
Rapptz
27c6d2c923 [commands] Add Cog.description to get the clean docstring. 2019-03-14 11:42:09 -04:00
Rapptz
c4a21cc1d4 [commands] Add Cog.qualified_name to query the specified cog name. 2019-03-13 23:43:29 -04:00
Rapptz
e1d9f8f59f [commands] Support staticmethod listeners and disallow them in commands 2019-03-12 11:54:45 -04:00
Rapptz
076f9bcac7 [commands] Fix name clash overwriting T.__class__.__name__
Fixes #1944
2019-02-28 19:47:25 -05:00
Rapptz
21a296d538 [commands] Error out when someone passes plain Cog.listener decorator.
Should make this error easier to catch rather than silent failure.
2019-02-27 21:38:55 -05:00
Rapptz
757584e651 [commands] Add support for stacking Cog.listener decorator.
Fix #1926
2019-02-27 04:29:54 -05:00
Rapptz
d5d9164810 [commands] Fix special method detection for regular function objects.
Fixes #1920
2019-02-24 00:24:31 -05:00
Rapptz
ab8e7b7732 [commands] Fix bug in behaviour in the cog inspection methods. 2019-02-23 10:51:23 -05:00
Rapptz
7ad4425c57 Update copyright years. 2019-02-23 09:26:39 -05:00
Rapptz
d3bc35a573 [commands] Update stale parent references in subcommands.
This bug was kind of a long one to figure out, as per #1918 documents
the issue had to do with subcommands but the actual adventure in
finding this one was a long one.

The first problem was that Command.cog was for some reason None, which
indicated that a copy was happening somewhere along the way. After some
fiddling I discovered that due to the copies of `Cog.__cog_commands__`
the groups pointed to out-dated versions that got overriden by the new
copies.

The first attempt at fixing this was straightforward -- just remove the
subcommand from the parent and replace it with the newer reference that
we just received. However, this ended up not working due to a strange
mystery where the subcommand being invoked was neither the original
copy nor the new copy residing in `Cog.__cog_commands__`.

Some more investigation later pointed out to me that a copy occurs
during the `Group.copy` stage which calls `Command.copy` for all its
subcommands. After spotting this out I had realised where the
discrepancy comes from. As it turns out, the subcommand copy that was
being invoked was actually a stale one created from `Group.copy`.

The question remained, how come that one was being called? The problem
stemmed from the fact that when the subcommand was copied, the parent
reference pointed to the old parent. Since the old parent was the one
that was getting the new reference, it went practically untouched. This
is because the calling code fetches the child from the parent and the
old parent is nowhere in the call chain.

To fix this issue we needed to update the parent reference, and in
order to do that a temporary lookup table is required pointing to the
latest copies that we have made.

Thus ends a 3.5 hour bug hunting adventure.
2019-02-23 09:26:01 -05:00
Rapptz
10ed41d8a0 [commands] Fix bug with cog bot check once not being unloaded properly. 2019-02-23 07:40:00 -05:00
Rapptz
1a0b1dfd29 [commands] Fix attribute access in cogs to commands.
Previously they were outdated copies, this updates the copies to the
ones that are actually injected.
2019-02-23 07:38:04 -05:00
Rapptz
f15cf7c845 [commands] Pass over kwargs to type.__new__ 2019-02-23 05:18:24 -05:00
Rapptz
caf3d17d4a Rework entire cog system and partially document it and extensions. 2019-02-23 04:10:10 -05:00