如何使用Interactions.py发送嵌入?

发布于 2025-02-13 19:10:14 字数 844 浏览 1 评论 0原文

我一直在尝试发送带有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

骄傲 2025-02-20 19:10:14

更新:我去了不和谐,并由于乐于助人的工作人员找到了答案。

对于其他遇到此问题的人:

此代码对我有用:

@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().green,
  timestamp=datetime.datetime.now())
await ctx.send(embeds=embed)

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:

@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().green,
  timestamp=datetime.datetime.now())
await ctx.send(embeds=embed)
如果没有 2025-02-20 19:10:14

从互动库中导入“嵌入”对我的

代码工作:

from interactions import Embed, slash_command, SlashContext

@slash_command(name="ping", description="for testing")
async def ping(ctx:SlashContext):
    embed = Embed(description="pong")
    await ctx.send(embed=embed)

希望这会有所帮助。

importing "Embed" from interactions library worked for me

code:

from interactions import Embed, slash_command, SlashContext

@slash_command(name="ping", description="for testing")
async def ping(ctx:SlashContext):
    embed = Embed(description="pong")
    await ctx.send(embed=embed)

I hope this helps.

蓬勃野心 2025-02-20 19:10:14
from interactions import Embed

async def embed(ctx: interactions.CommandContext):
  embed = Embed(
    title="your title",
    description="your description",
    color=discord.Color.random(),
    timestamp=datetime.datetime.now())
  await ctx.send(embed=embed)
from interactions import Embed

async def embed(ctx: interactions.CommandContext):
  embed = Embed(
    title="your title",
    description="your description",
    color=discord.Color.random(),
    timestamp=datetime.datetime.now())
  await ctx.send(embed=embed)
不可一世的女人 2025-02-20 19:10:14

您必须更改命令的名称或命令的名称,并使用不嵌入ctx的嵌入。

@client.command(
name="embed",
description="Test",
scope=[993586870606905404],
)
async def embed(ctx: interactions.CommandContext):
embed_message = discord.Embed(
  title="your title",
  description="your description",
  color=discord.Color().green,
  timestamp=datetime.datetime.now())
await ctx.send(embeds=embed_message)

You must change the name of the embed or the name of the command and use embeds not embed for await ctx.send(embeds=...)

@client.command(
name="embed",
description="Test",
scope=[993586870606905404],
)
async def embed(ctx: interactions.CommandContext):
embed_message = discord.Embed(
  title="your title",
  description="your description",
  color=discord.Color().green,
  timestamp=datetime.datetime.now())
await ctx.send(embeds=embed_message)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文