@@ -942,19 +942,36 @@ def _error_handler_exists(self, handler_name):
942
942
)
943
943
944
944
def _inject_cogs (self , cog ):
945
- for cmd in self .commands .values ():
945
+ # Insert the cog into slash commands:
946
+ if not hasattr (cog , "slash_commands" ):
947
+ cog .slash_commands = []
948
+ for cmd in self .slash_commands .values ():
949
+ if cmd ._cog_class_name == cog .__class__ .__name__ :
950
+ cmd ._inject_cog (cog )
951
+ cog .slash_commands .append (cmd )
952
+ # Insert the cog into user commands:
953
+ if not hasattr (cog , "user_commands" ):
954
+ cog .user_commands = []
955
+ for cmd in self .user_commands .values ():
946
956
if cmd ._cog_class_name == cog .__class__ .__name__ :
947
957
cmd ._inject_cog (cog )
958
+ cog .user_commands .append (cmd )
959
+ # Insert the cog into message commands:
960
+ if not hasattr (cog , "message_commands" ):
961
+ cog .message_commands = []
962
+ for cmd in self .message_commands .values ():
963
+ if cmd ._cog_class_name == cog .__class__ .__name__ :
964
+ cmd ._inject_cog (cog )
965
+ cog .message_commands .append (cmd )
966
+ # Auto register the commands again
948
967
if self .is_ready :
949
968
self .client .loop .create_task (self ._auto_register_or_patch ())
950
969
# We need to know which cogs are able to dispatch errors
951
970
pairs = cog .get_listeners ()
952
- for name , func in pairs :
953
- # Loop through all error listener types
954
- for event_name , cog_names in self ._cogs_with_err_listeners .items ():
955
- if name == event_name :
956
- cog_names .append (cog .qualified_name )
957
- break
971
+ for event_name , func in pairs :
972
+ cog_names = self ._cogs_with_err_listeners .get (event_name )
973
+ if cog_names is not None :
974
+ cog_names .append (cog .qualified_name )
958
975
959
976
def _eject_cogs (self , name ):
960
977
for cog_names in self ._cogs_with_err_listeners .values ():
0 commit comments