【问题标题】:discord.py user embed title input only taking one worddiscord.py 用户嵌入标题输入只取一个词
【发布时间】:2021-06-18 16:53:20
【问题描述】:

我有这个命令叫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)

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以将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)
    

    【讨论】:

    • 为了更简单,您也可以使用color, title, description = content.split('/', 3),它也可以正常工作
    • 哦,好吧,不知道@Bagle
    猜你喜欢
    • 2021-03-19
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    • 2021-04-09
    • 2021-06-18
    • 2019-05-28
    • 2021-04-09
    • 1970-01-01
    相关资源
    最近更新 更多