Skip to content

Instantly share code, notes, and snippets.

@DriftAsimov
Last active January 12, 2022 06:09
Show Gist options
  • Save DriftAsimov/cf993824343a9d369b38f6a08d2946df to your computer and use it in GitHub Desktop.
Save DriftAsimov/cf993824343a9d369b38f6a08d2946df to your computer and use it in GitHub Desktop.
Discord.py hardcoded help command but it's better
@bot.command()
async def help(ctx: commands.Context, *, name: str = None):
name = name.strip()
if not name:
commands = bot.commands
embed = discord.Embed(title="Commands Menu", color=0x8DDFE3)
embed.set_thumbnail(url=bot.user.avatar_url)
for name, cog in bot.cogs.items():
embed.add_field(
name=cog.qualified_name,
value=", ".join([i.name for i in cog.get_commands()]),
inline=False,
)
misc = ", ".join([i.name for i in bot.commands if not i.cog])
if len(misc) > 1:
embed.add_field(name="Miscellanous", value=misc)
await ctx.send(embed=embed)
else:
if name.lower() in [i.lower() for i in bot.cogs]:
raw_cog = [i for i in bot.cogs if name.lower() == i.lower()][0]
clog = bot.get_cog(raw_cog)
embed = discord.Embed(color=0x8DDFE3)
embed.title = clog.qualified_name
embed.description = clog.description
for command in clog.get_commands():
embed.add_field(name=command.name, value=command.short_doc)
await ctx.send(embed=embed)
elif name.lower() in [i.name.lower() for i in bot.commands]:
await ctx.send("ay")
command = [i for i in bot.commands if name.lower() == i.name.lower()][0]
if not hasattr(command, "commands"):
embed = discord.Embed(
title=command.name, description=command.short_doc, color=0x8DDFE3
)
embed.add_field(
name="Usage",
value=f"{ctx.prefix}{command.qualified_name} {command.signature}",
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title=command.name, description=command.short_doc, color=0x8DDFE3
)
for child in list(command.commands):
embed.add_field(
name=child.name, value=f"{command.name} {child.name}"
)
await ctx.send(embed=embed)
@DriftAsimov
Copy link
Author

Arigato! I am totally not late in replying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment