This commit is contained in:
Slipstream 2025-04-27 01:01:35 -06:00
parent 33e15df5be
commit d856e4ccef
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 26 additions and 3 deletions

View File

@ -132,8 +132,19 @@ class GurtCog(commands.Cog, name="Gurt"): # Added explicit Cog name
# --- Setup Commands and Listeners ---
# Add commands defined in commands.py
self.command_functions = setup_commands(self)
# Store command functions for reference
self.registered_commands = [func.__name__ for func in self.command_functions]
# Store command names for reference - safely handle Command objects
self.registered_commands = []
for func in self.command_functions:
# For app commands, use the name attribute directly
if hasattr(func, "name"):
self.registered_commands.append(func.name)
# For regular functions, use __name__
elif hasattr(func, "__name__"):
self.registered_commands.append(func.__name__)
else:
self.registered_commands.append(str(func))
# Add listeners defined in listeners.py
# Note: Listeners need to be added to the bot instance, not the cog directly in this pattern.
# We'll add them in cog_load or the main setup function.

View File

@ -276,7 +276,19 @@ def setup_commands(cog: 'GurtCog'):
command_functions.append(gurtsync)
print(f"Gurt commands setup in cog: {[func.__name__ for func in command_functions]}")
# Get command names safely - Command objects don't have __name__ attribute
command_names = []
for func in command_functions:
# For app commands, use the name attribute directly
if hasattr(func, "name"):
command_names.append(func.name)
# For regular functions, use __name__
elif hasattr(func, "__name__"):
command_names.append(func.__name__)
else:
command_names.append(str(func))
print(f"Gurt commands setup in cog: {command_names}")
# Return the command functions for proper registration
return command_functions