我想知道是否有办法获取命令的参数以显示如何使用它。我有一个自定义的帮助命令,但我尝试使用与您在装饰器中放置的相同的描述内容。它不起作用(不会给我任何错误或任何东西),但我不知道为什么。
@commands.command()
async def format(self, ctx, command):
formatting = discord.Embed(title=f"Formatting for .{command}", description=command.description)
formatting.set_thumbnail(url=self.bot.avatar_url)
formatting.set_footer(text=f"Requested by {ctx.author.mention}", icon_url=ctx.author.avatar_url)
ctx.send(embed=formatting)
这是我的命令之一,其中包含描述内容:
"""Change Nickname command"""
@commands.command(aliases=['chnick'], description="Usage: .nick [member mention] [nickname to change to]")
@commands.has_permissions(manage_channels=True)
async def change_nick(self, ctx, member: discord.Member, nick):
"""Changes a user's nickname\nAliases: chnick"""
await member.edit(nick=nick)
await ctx.send(f"Nickname was changed for {member.mention}")
答案 0 :(得分:0)
您需要使用 get_command()
@commands.command()
async def format(self, ctx, command):
command = self.bot.get_command(command)
formatting = discord.Embed(title=f"Formatting for .{command.name}", description=command.description)
formatting.set_thumbnail(url=self.bot.avatar_url)
formatting.set_footer(text=f"Requested by {ctx.author.mention}", icon_url=ctx.author.avatar_url)
await ctx.send(embed=formatting)