我正在制作一个创建角色的命令,这是代码:
@client.command()
@has_permissions(administrator=True)
async def createrole(ctx, * name):
guild = ctx.guild
await guild.create_role(name=name)
但当我运行它时,它告诉我:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In name: Could not interpret "[New Role]" as string.
您没有得到有效的名称,*
和name
之间有一个额外的空格。
请在这里阅读更多
@client.command()
@has_permissions(administrator=True)
async def createrole(ctx, *name):
await ctx.guild.create_role(name=name)