如何删除默认帮助命令或更改discord.py中的格式

时间:2017-08-30 03:03:43

标签: python discord.py

如何删除discord.py中的默认帮助命令?或者至少改变格式。但我认为改变格式会很好,我根本不喜欢这种格式。而且我一直在研究如何至少改变格式或删除命令。请回答,谢谢。 :)

5 个答案:

答案 0 :(得分:4)

试试这个:

  

bot.remove_command('帮助&#39)

在导入后将它放在代码的顶部。 然后创建自己的。

或者要格式化,请查看:Click here!

答案 1 :(得分:3)

例如,您将需要删除命令

@foreach($aboutcontent as $key => $about)
 @if($key == 0)
  @continue
 @endif
 code
@endforeach

您需要将其放在

client.remove_command('help')

就像

client = commands.Bot

答案 2 :(得分:0)

这是应该执行的操作,以便它可以保留help命令的行为,同时让您更改其外观:

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```

有关更多详细信息,请参见文档:https://discordpy.readthedocs.io/en/rewrite/ext/commands/api.html#help-commands

要从旧的helpformatter迁移:https://discordpy.readthedocs.io/en/rewrite/migrating.html#helpformatter-and-help-command-changes

答案 3 :(得分:0)

这些答案不正确。根据{{​​3}}禁用帮助命令的正确方法是将help_command=None传递到discord.ext.commands.Bot的构造函数中,例如:

bot = commands.Bot(help_command=None)

class MyBot(commands.Bot):
    def __init__(self):
        super().__init__(help_command=None)

这还使您有机会将自己的帮助功能传递到help_command参数中以进行不同的格式设置。

答案 4 :(得分:-1)

你真的不需要删除命令......这不好,使用(前缀)帮助命令名<-它不会出现......如果你想要它嵌入你可以做。

class NewHelpName(commands.MinimalHelpCommand):
    async def send_pages(self):
        destination = self.get_destination()
        for page in self.paginator.pages:
            emby = discord.Embed(description=page)
            await destination.send(embed=emby)
client.help_command = NewHelpName()```
The built in help command is of great use
相关问题