Python 在discord.py中嵌入发送方,带有三个自定义参数

Python 在discord.py中嵌入发送方,带有三个自定义参数,python,discord,discord.py,Python,Discord,Discord.py,我正在尝试制作一个简单的嵌入发送器,它包含以下部分:标题、描述和页脚 这是我的密码: @bot.command() async def embed(ctx, *, title, desc, footer): embed = discord.Embed(title=f"{title}", description=f"{desc}", color=0x00ff00) embed.set_footer(text=f"{footer}&q

我正在尝试制作一个简单的嵌入发送器,它包含以下部分:标题、描述和页脚

这是我的密码:

@bot.command()
async def embed(ctx, *, title, desc, footer):
    embed = discord.Embed(title=f"{title}", description=f"{desc}", color=0x00ff00)
    embed.set_footer(text=f"{footer}")
    await ctx.send(embed=embed)
我的错误是:

Traceback (most recent call last):
  File "C:\Users\Ryzen\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Ryzen\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Ryzen\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 92, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: embed() missing 2 required keyword-only arguments: 'desc' and 'footer'

谢谢您的帮助。

*
之后只能有一个参数,所有剩余的数据都将在这个参数中传递

例如:
async def嵌入(ctx,title,desc,*,footer)

如果您传递以下命令:
!嵌入Lorem ipsum dolor sit amet

您将获得如下所示的变量:

title = "Lorem"
desc = "ipsum"
footer = "dolor sit amet"

在命令中,
*
将获得它后面的所有内容,使用变量将使它成为一个单词

使用
*
将所有数据作为一个变量获取。您必须以某种方式分割数据,我在这里使用了
-
,这将生成代码中注释的stings索引列表

像这样使用
{prefix}此处嵌入标题-此处描述-此处页脚

@bot.command()
异步def嵌入(ctx,*,数据):
data=data.split('-')#title=0,desc=1,footer=2
嵌入=不和谐。嵌入(
title=f“{data[0]}”,description=f“{data[1]}”,color=0x00ff00)
嵌入.set_页脚(text=f“{data[2]}”)
等待ctx.send(嵌入=嵌入)

您还可以使用引号将长字符串传递给变量:

异步定义嵌入(ctx、标题、描述、页脚):
嵌入=不协调。嵌入(标题=标题,描述=描述,颜色=0x00ff00)
嵌入.设置页脚(文本=页脚)
等待ctx.send(嵌入=嵌入)
用法:
{prefix}嵌入“title here”“desc here”“footer here”