You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用discord.py开发Slash命令机器人发送Embed报错排查

问题分析

你犯了两个关键的API混用错误:

  1. 你使用的是discord-py-interactions库的interactions.Client,但调用ctx.send()时用了原生discord.py的embed参数——这个库的send方法不支持该参数,对应的正确参数是**embeds**(复数形式)。
  2. 虽然可以传入原生discord.Embed对象,但更推荐使用interactions库自带的Embed类,避免跨库API不兼容问题。
修复后的代码
import interactions
import discord

intents = discord.Intents.default()
intents.message_content = True

bot = interactions.Client(token=TOKEN)

@bot.command(
  name="debug",
  description="Test for errors in bot",
  scope=<id>,  # 替换为你的服务器ID
)
async def debug(ctx: interactions.CommandContext):
    # 方式1:使用interactions库的Embed类(推荐)
    help_embed = interactions.Embed(title="Modules:")
    await ctx.send(embeds=help_embed)
    
    # 方式2:兼容原生discord.Embed(需用embeds参数)
    # help_embed = discord.Embed(title="Modules:")
    # await ctx.send(embeds=help_embed)

bot.start()
补充说明
  • interactions库的send方法中,embeds参数既可以传单个Embed实例,也可以传多个实例组成的列表。
  • 确保已正确安装依赖:pip install discord-py-interactions

内容的提问来源于stack exchange,提问作者i cant think of a name

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 20:13:07