如何使用Interactions.py发送嵌入?
我一直在尝试发送带有Interactions.py的嵌入。但是,它不会像discord.py一样工作。
这是错误的代码:
@client.command(
name="embed",
description="Test",
scope=[993586870606905404],
)
async def embed(ctx: interactions.CommandContext):
embed = discord.Embed(
title="your title",
description="your description",
color=discord.Color.random(),
timestamp=datetime.datetime.now())
await ctx.send(embed=embed)
但是,我不断收到以下错误:
Traceback (most recent call last):
File "/Users/my.computer/bot.py/main.py", line 79, in embed
await ctx.send(embed=embed)
File "/Users/my.computer/venv/lib/python3.10/site-packages/interactions/client/context.py", line 445, in send
payload = await super().send(content, **kwargs)
TypeError: _Context.send() got an unexpected keyword argument 'embed'
请帮助我解决此问题!我在互联网上的任何地方都找不到答案。
I have been trying to send an embed with interactions.py, a rewrite (to my understanding) of discord.py. However, it won't work as it does with discord.py.
Here is the faulty code:
@client.command(
name="embed",
description="Test",
scope=[993586870606905404],
)
async def embed(ctx: interactions.CommandContext):
embed = discord.Embed(
title="your title",
description="your description",
color=discord.Color.random(),
timestamp=datetime.datetime.now())
await ctx.send(embed=embed)
However, I keep getting the following error:
Traceback (most recent call last):
File "/Users/my.computer/bot.py/main.py", line 79, in embed
await ctx.send(embed=embed)
File "/Users/my.computer/venv/lib/python3.10/site-packages/interactions/client/context.py", line 445, in send
payload = await super().send(content, **kwargs)
TypeError: _Context.send() got an unexpected keyword argument 'embed'
Please help me fix this! I can't find the answer anywhere on the internet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
更新:我去了不和谐,并由于乐于助人的工作人员找到了答案。
对于其他遇到此问题的人:
此代码对我有用:
Update: I went to the discord and found the answer due to the helpful staff.
For anyone else having this issue:
This code worked for me:
从互动库中导入“嵌入”对我的
代码工作:
希望这会有所帮助。
importing "Embed" from interactions library worked for me
code:
I hope this helps.
您必须更改命令的名称或命令的名称,并使用不嵌入ctx的嵌入。
You must change the name of the embed or the name of the command and use embeds not embed for await ctx.send(embeds=...)