首页 > 解决方案 > 自定义嵌入未显示

问题描述

我正在制作机器人,它需要一个命令后跟一个输出嵌入的字符串

我的想法是让它遵循以下准则: al_emb "Title Here" "Description Here"

到目前为止我的代码:

@bot.command()
async def emb(c,embed):
    #first = c.content.split()[1]
    #second = c.content.split()[2]
    first = c.content
    #embed = embed.Embed(title=first, description=second, color=0x00ff00)
    embed = embed.Embed(title=first, color=0x00ff00)
    await c.send(embed=embed)

我没有输出

非常感谢任何帮助

标签: pythonpython-3.xdiscorddiscord.py

解决方案


您可以在协程的签名中包含两个参数:

class MyCog(commands.Cog):
    @commands.command()
    async def emb(self, ctx, title, description):
        embed = discord.Embed(title=title, description=description, color=0x00ff00)
        await ctx.send(embed=embed)

推荐阅读