如何删除或更改默认的帮助命令?
How to remove or change the default help command?
如何删除或至少更改 discord.py 中默认帮助命令的格式?
我认为改变格式会很好,我一点也不喜欢这种格式。
试试这个:
bot.remove_command('help')
将它放在代码的顶部,在导入之后。
然后创建你自己的。
或格式化它检查这个:Click here!
例如,您需要删除命令
client.remove_command('help')
你需要把它放在
下面
client = commands.Bot
会像
client = commands.Bot(command_prefix = 'somethingelse')
client.remove_command('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。
从旧的帮助格式化程序迁移:https://discordpy.readthedocs.io/en/rewrite/migrating.html#helpformatter-and-help-command-changes
根据docs禁用帮助命令的正确方法是将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
参数中以用于不同的格式。
你真的不需要删除命令......这不好,使用(前缀)帮助命令名< - 它不会出现......如果你想要它嵌入你可以做到。
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
在这里你可以使用这个:
intents = discord.Intents.all()
activity = discord.Game(name=f"!help in {len(client.guilds)} servers!")
client = commands.Bot(command_prefix="!", intents=intents, activity=activity, status=discord.Status.do_not_disturb, help_command=None)
如何删除或至少更改 discord.py 中默认帮助命令的格式?
我认为改变格式会很好,我一点也不喜欢这种格式。
试试这个:
bot.remove_command('help')
将它放在代码的顶部,在导入之后。 然后创建你自己的。
或格式化它检查这个:Click here!
例如,您需要删除命令
client.remove_command('help')
你需要把它放在
下面client = commands.Bot
会像
client = commands.Bot(command_prefix = 'somethingelse')
client.remove_command('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。
从旧的帮助格式化程序迁移:https://discordpy.readthedocs.io/en/rewrite/migrating.html#helpformatter-and-help-command-changes
根据docs禁用帮助命令的正确方法是将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
参数中以用于不同的格式。
你真的不需要删除命令......这不好,使用(前缀)帮助命令名< - 它不会出现......如果你想要它嵌入你可以做到。
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
在这里你可以使用这个:
intents = discord.Intents.all()
activity = discord.Game(name=f"!help in {len(client.guilds)} servers!")
client = commands.Bot(command_prefix="!", intents=intents, activity=activity, status=discord.Status.do_not_disturb, help_command=None)