简体   繁体   English

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

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

I have this command called p!customembed [color] [title] [description] .我有这个命令叫做p!customembed [color] [title] [description] It's basically what it sounds like.这基本上就是它听起来的样子。 However, there is one flaw.但是,有一个缺陷。 I want my bot to send a blue embed with the title being "potatoes are nice" and the description being "test".我希望我的机器人发送一个蓝色嵌入,标题为“土豆很好”,描述为“测试”。 However, the title is "potatoes" and the description "are nice test".但是,标题是“土豆”,描述是“很好的测试”。 I was thinking of separating the title and description in the ctx command with something like / , like p!customembed [color] [title] / [description] to separate the two, but I have no clue how to do it.我正在考虑用/之类的东西将 ctx 命令中的标题和描述分开,例如p!customembed [color] [title] / [description]将两者分开,但我不知道该怎么做。 Can anyone help?任何人都可以帮忙吗? Thx谢谢

@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)

You can do it with replacing color, title, *, description with content and then split the content up (you would have to remake your command a bit).您可以通过将color, title, *, description替换为content然后拆分内容来完成此操作(您必须稍微重新制作命令)。

Revised example:修改示例:

Command:命令:

p!customembed /color/title/description

Code:代码:

@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