14 Commits

Author SHA1 Message Date
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