繁体   English   中英

discord.py 用户嵌入标题输入只取一个字

[英]discord.py user embed title input only taking one word

我有这个命令叫做p!customembed [color] [title] [description] 这基本上就是它听起来的样子。 但是,有一个缺陷。 我希望我的机器人发送一个蓝色嵌入,标题为“土豆很好”,描述为“测试”。 但是,标题是“土豆”,描述是“很好的测试”。 我正在考虑用/之类的东西将 ctx 命令中的标题和描述分开,例如p!customembed [color] [title] / [description]将两者分开,但我不知道该怎么做。 任何人都可以帮忙吗? 谢谢

@client.command()
async def customembed(ctx, color: discord.Colour, title, *, description):
    embed = discord.Embed(title=title, description=description, color=color)
    await ctx.send(embed=embed)

您可以通过将color, title, *, description替换为content然后拆分内容来完成此操作(您必须稍微重新制作命令)。

修改示例:

命令:

p!customembed /color/title/description

代码:

@client.command()
async def customembed(ctx, content):
    color, title, description = content.split('/', 3)

    embed = discord.Embed(title=title, description=description, color=int(color))
    await ctx.send(embed=embed)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM