Haley
Haley

Reputation: 47

How to change the help command in discord.py

I have recently found the following screenshot and I was wondering how it is possible to get this behavior using discord.py in my discord bot.

enter image description here

Upvotes: 2

Views: 1332

Answers (1)

Shunya
Shunya

Reputation: 2449

What you are looking at is a customized discord-like chat from Xenon. This chat allows you to Discord-like chat section, but emulates the behaviour of Discord. Xenon is open source, so just check their repositories if you want to do the same as they do.

If you want to customize the help command of your bot, which all bots have, you can do it with the recent changes of discord.py-rewrite. Toa chieve what you want you will need to subclass HelpCommand or MinimalHelpCommand, then pass it to bot.help_command.

The following code shows the standard way of subclassing MinimalHelpCommand:

class MyHelpCommand(commands.MinimalHelpCommand):
    def get_command_signature(self, command):
        return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command)

class MyCog(commands.Cog):
    def __init__(self, bot):
        self._original_help_command = bot.help_command
        bot.help_command = MyHelpCommand()
        bot.help_command.cog = self

    def cog_unload(self):
        self.bot.help_command = self._original_help_command

For more info, discord.py documentation: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#help-commands

Upvotes: 1

Related Questions