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

问题描述 投票:0回答:4

我一直在尝试发送嵌入的interactions.py,重写(根据我的理解)discord.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'

请帮我解决这个问题!我在互联网上找不到答案。

python discord discord.py
4个回答
3
投票

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

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

这段代码对我有用:

@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)

0
投票

从交互库导入“嵌入”对我有用

代码:

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)

我希望这有帮助。


0
投票
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)

-2
投票

您必须更改嵌入的名称或命令的名称,并使用嵌入而不是嵌入 for wait 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)
© www.soinside.com 2019 - 2024. All rights reserved.