Reputation: 80
Hi I’m trying to code a simple discord bot using discord.py, and one of the things I want my bot to do is send a nice custom embed when a user uses the !help command. So far I know that this simple code, which some people provided in other questions on stackoverflow about custom help commands:
class help(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
e = discord.Embed(title="Help:", description="description", colour=discord.Colour.blurple(), timestamp=datetime.datetime.utcnow())
await destination.send(embed=e)
client.help_command = help()
works, but the thing is when someone wants to use !help on a specific command or category, the bot will only send the send_pages command. I tried modifying the code and added
async def send_page_command(self, *, command):
destination = self.get_destination
command_e = discord.Embed(title="Dogluva:robot's Help:", description=f"{command.description}", colour=discord.Colour.blurple(), timestamp=datetime.datetime.utcnow())
await destination.send(embed=command_e)
But this doesn’t help. Anyone know what I’m doing wrong here? I’ve set the description for all the commands I wrote in my cogs using commands.command(description=“description")
but I don’t know how to make a custom help command access those descriptions.
Upvotes: 0
Views: 1538
Reputation: 80
@client.command()
async def help(ctx, *, command=None):
if command == None:
e = discord.Embed(title="Dogluva:robot:'s Help:", description=“Custom Description", colour=discord.Colour.blurple(), timestamp=datetime.datetime.utcnow())
elif command == “{command}":
e = discord.Embed(title="Dogluva:robot:'s Help:", description=“Command Description", colour=discord.Colour.blurple(), timestamp=datetime.datetime.utcnow())
await ctx.send(embed=e)
I just created different cases for each command
Upvotes: 0
Reputation: 3
instead of send_page_command(self, *, command):
you can try using send_command_help(self, command):
https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96
Upvotes: 0
Reputation: 2663
First, remember to delete the default help command (discord automatically has help command), so you need to delete it first:
client.remove_command('help') # before your own "help" command
# or
client = commands.Bot(command_prefix="<your prefix>", help_command=None) # when you create client
Basic help command:
@client.command()
async def help(ctx):
embed = discord.Embed(title="Help", description="Write your own description here", colour=discord.Color.blue())
await ctx.send(embed=embed)
But you can make it even better. Read more about Embeds in the documentation and check this template:
Upvotes: 1