Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically sort commands into different categories in /help list #380

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
"rank": {
"name": "Rank",
"description": "Show your bot level/rank, or someone else's level/rank.",
"type": "leveling system",
"type": "levelling",
"cooldown": null,
"args": ["user (optional)"],
"usable_by": "everyone",
Expand All @@ -422,7 +422,7 @@
"edit_rank": {
"name": "Edit Member Rank",
"description": "Sets a new level/rank for a specified user.",
"type": "leveling system/DevTools",
"type": "DevTools",
"cooldown": null,
"args": ["user", "new_rank"],
"usable_by": "the developer",
Expand All @@ -432,7 +432,7 @@
"edit_xp": {
"name": "Edit Member XP",
"description": "Sets a new XP amount for a specified user.",
"type": "leveling system/DevTools",
"type": "DevTools",
"cooldown": null,
"args": ["user", "new_xp"],
"usable_by": "the developer",
Expand Down
46 changes: 35 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async def on_application_command_error(ctx: ApplicationContext, error: discord.D
await ctx.respond(f"An uncaught error occured while running the command. (don't worry, developers will fix this soon)\n```\n{error}\n```")

# Help Commands
help_cmds = discord.commands.SlashCommandGroup("help", "Commands used for getting command help in the bot.")
help_cmds = client.create_group("help", "Commands used for getting command help in the bot.")

@help_cmds.command(
name="list",
Expand All @@ -283,20 +283,44 @@ async def help_list(ctx: ApplicationContext, search: str = None):
"""Get a list of all bot commands, or search for specific commands."""
commandsdb = _commands.fetch_raw()
commands_list = str()
localembed = None

if search is not None:
for _command in commandsdb:
if (search in _command) and (commandsdb[_command]["type"] != "DevTools"):
commands_list += f"`/{_command}`\n"
if commands_list == "":
commands_list = "*No commands were found*"
localembed = discord.Embed(title="Isobot Command Help", description=f"**Bot Commands:**\n{commands_list}", color=color)
await ctx.respond(embed=localembed)

for _command in commandsdb:
if commandsdb[_command]["type"] != "DevTools":
commands_list += f"`/{_command}`\n"
commands_list += f"`/{_command}` "
if commands_list == "":
commands_list = "*No commands were found*"
localembed = discord.Embed(title="Isobot Command Help", description=f"**Bot Commands:**\n{commands_list}", color=color)
await ctx.respond(embed=localembed)
localembed.set_footer(text=f"Search results for \"{search}\"")

else:
economy_commands = str()
levelling_commands = str()
utility_commands = str()
fun_commands = str()
reddit_commands = str()
afk_commands = str()
automod_moderation_commands = str()
maths_commands = str()
other_commands = str()
for _command in commandsdb:
command_type = commandsdb[_command]["type"]
if commandsdb[_command]["type"] != "DevTools":
if command_type == "economy system" or command_type == "minigames": economy_commands += f"`/{_command}` "
elif command_type == "levelling": levelling_commands += f"`/{_command}` "
elif command_type == "general utilities": utility_commands += f"`/{_command}` "
elif command_type == "fun": fun_commands += f"`/{_command}` "
elif command_type == "reddit media": reddit_commands += f"`/{_command}` "
elif command_type == "AFK system": afk_commands += f"`/{_command}` "
elif command_type == "automod" or command_type == "moderation": automod_moderation_commands += f"`/{_command}` "
elif command_type == "maths": maths_commands += f"`/{_command}` "
else: other_commands += f"`/{_command}` "

commands_list = f"**:money_with_wings: Economy System:**\n{economy_commands}\n\n**:arrow_up: Levelling System:**\n{levelling_commands}\n\n**:toolbox: Utilities:**\n{utility_commands}\n\n**:joy: Fun Commands:**\n{fun_commands}\n\n**:crescent_moon: AFK System**\n{afk_commands}\n\n**:tools: Moderation and Automod:**\n{automod_moderation_commands}\n\n**:1234: Maths Commands:**\n{maths_commands}\n\n**:frame_photo: Reddit Media Commands:**\n{reddit_commands}\n\n**:sparkles: Miscellaneous:**\n{other_commands}"
localembed = discord.Embed(title="Isobot Command Help", description=commands_list, color=color)
localembed.set_footer(text="Run \"/help info\" to get more information on a command.")
await ctx.respond(embed=localembed)

@help_cmds.command(
name="info",
Expand Down
Loading