Created
November 17, 2021 09:22
-
-
Save ThatGenZGamer48/f47d5919ec0dc2e41fa75cf8aa76aeff to your computer and use it in GitHub Desktop.
Discord.py 2.0 or PyCord 2.0 Automatic Help Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
import os | |
bot = commands.Bot( | |
command_prefix='!', | |
intents=discord.Intents(members=True, messages=True, guilds=True), | |
help_command=None # This is important to create custom help command! | |
) | |
# Below is the custom help command | |
# It works on cogs as well | |
# But it does not display non-cog commands | |
# I will edit it later to display non-cog commands as well | |
@bot.command(description='Shows all the commands of the bot') | |
async def help(ctx): | |
cog_names = [cog for cog in bot.cogs] | |
embed = discord.Embed( | |
title='Help', | |
colour=discord.Colour.og_blurple(), # You can change the color | |
timestamp=discord.utils.utcnow() | |
) | |
for cog_name in cog_names: | |
commands = [] | |
for command in bot.get_cog(cog_name).walk_commands(): | |
commands.append(f'`{command.name}`') | |
command_list = ", ".join(commands) | |
embed.add_field(name=cog_name, value=command_list, inline=False) | |
await ctx.send(embed=embed) | |
bot.run('your token here') # replace your token here with your actual discord bot token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool