feat: Add command to list available command groups for debugging
This commit is contained in:
parent
92c07a8430
commit
0008327bd0
@ -239,7 +239,12 @@ class SettingsCog(commands.Cog, name="Settings"):
|
||||
# Validate the original group exists
|
||||
group_found = False
|
||||
for cmd in self.bot.tree.get_commands():
|
||||
if hasattr(cmd, 'parent') and cmd.parent and cmd.parent.name == original_name:
|
||||
# Check if this command is itself a group with the specified name
|
||||
if hasattr(cmd, 'name') and cmd.name == original_name and hasattr(cmd, 'commands'):
|
||||
group_found = True
|
||||
break
|
||||
# Also check if this is a subcommand of a group with the specified name (for nested groups)
|
||||
elif hasattr(cmd, 'parent') and cmd.parent and cmd.parent.name == original_name:
|
||||
group_found = True
|
||||
break
|
||||
|
||||
@ -377,6 +382,40 @@ class SettingsCog(commands.Cog, name="Settings"):
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command(name='listgroups', help="Lists all available command groups for debugging.")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.guild_only()
|
||||
async def list_groups(self, ctx: commands.Context):
|
||||
"""Lists all available command groups for debugging purposes."""
|
||||
groups = []
|
||||
commands_list = []
|
||||
|
||||
for cmd in self.bot.tree.get_commands():
|
||||
# Check if this is a group
|
||||
if hasattr(cmd, 'commands') and hasattr(cmd, 'name'):
|
||||
groups.append(f"`{cmd.name}` - {getattr(cmd, 'description', 'No description')}")
|
||||
# Check if this is a regular command
|
||||
elif hasattr(cmd, 'name'):
|
||||
commands_list.append(f"`{cmd.name}`")
|
||||
|
||||
embed = discord.Embed(title="Available Command Groups & Commands", color=discord.Color.green())
|
||||
|
||||
if groups:
|
||||
groups_text = "\n".join(groups[:10]) # Limit to first 10 to avoid message length issues
|
||||
if len(groups) > 10:
|
||||
groups_text += f"\n... and {len(groups) - 10} more groups"
|
||||
embed.add_field(name="Command Groups", value=groups_text, inline=False)
|
||||
else:
|
||||
embed.add_field(name="Command Groups", value="No groups found", inline=False)
|
||||
|
||||
if commands_list:
|
||||
commands_text = ", ".join(commands_list[:20]) # Limit to first 20
|
||||
if len(commands_list) > 20:
|
||||
commands_text += f", ... and {len(commands_list) - 20} more commands"
|
||||
embed.add_field(name="Individual Commands", value=commands_text, inline=False)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command(name='synccmds', help="Syncs slash commands with Discord to apply customizations.")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.guild_only()
|
||||
@ -497,6 +536,7 @@ class SettingsCog(commands.Cog, name="Settings"):
|
||||
@reset_group_name.error
|
||||
@add_command_alias.error
|
||||
@remove_command_alias.error
|
||||
@list_groups.error
|
||||
@sync_commands.error
|
||||
@modlog_config_group.error # Add error handler for the group
|
||||
@modlog_enable.error
|
||||
|
Loading…
x
Reference in New Issue
Block a user