@client.command 中的空格?

时间:2021-01-24 21:01:26

标签: python discord discord.py

如何在我的命令中创建一个不再是 useitem 而是使用 item 的空格?

因为目前输入这样的命令看起来很不正经

@client.command()
async def use20items (ctx):
    Pflanzen= await ctx.send ('**test**')
    await asyncio.sleep(10)
    await Pflanzen.edit(content='message')

2 个答案:

答案 0 :(得分:1)

您可以在装饰器中传递命令的名称:

@client.command(name="use item")
async def ...

答案 1 :(得分:0)

您可以使用别名添加空格,如下例所示:

@client.command(aliases=["use item"])
async def use_item(ctx):
    ...

我可以看到您在 use20items(ctx) 之间有一个空格,而 ctx.send('**test**') 这样做可能会导致错误。 我希望这会有所帮助。