我一直在尝试发送嵌入的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'
请帮我解决这个问题!我在互联网上找不到答案。
更新:由于工作人员乐于助人,我去了不和谐并找到了答案。
对于其他遇到此问题的人:
这段代码对我有用:
@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)
从交互库导入“嵌入”对我有用
代码:
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)
我希望这有帮助。
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)
您必须更改嵌入的名称或命令的名称,并使用嵌入而不是嵌入 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)