File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ Command
1919.. autoclass :: revolt.ext.commands.Command
2020 :members:
2121
22+ Cog
23+ ~~~~
24+ .. autoclass :: revolt.ext.commands.Cog
25+ :members:
26+
2227command
2328~~~~~~~~
2429.. autodecorator :: revolt.ext.commands.command
Original file line number Diff line number Diff line change @@ -32,18 +32,30 @@ class Cog(metaclass=CogMeta):
3232 _commands : list [Command ]
3333 qualified_name : str
3434
35- def _inject (self , client : CommandsClient ):
35+ def cog_load (self ):
36+ """A special method that is called when the cog gets loaded."""
37+ pass
38+
39+ def cog_unload (self ):
40+ """A special method that is called when the cog gets removed."""
41+ pass
42+
43+ def _inject (self , client : CommandsClient ):
3644 client .cogs [self .qualified_name ] = self
3745
3846 for command in self ._commands :
3947 command .cog = self
4048 client .add_command (command )
4149
50+ self .cog_load ()
51+
4252 def _uninject (self , client : CommandsClient ):
4353 for name , command in client .all_commands .copy ().items ():
4454 if command in self ._commands :
4555 del client .all_commands [name ]
4656
57+ self .cog_unload ()
58+
4759 @property
4860 def commands (self ) -> list [Command ]:
4961 return self ._commands
You can’t perform that action at this time.
0 commit comments