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

发送带按钮的Discord临时消息报错:send_with_components不支持ephemeral参数

问题原因与解决方法

错误原因

ephemeral 是Discord交互响应专属参数,仅用于交互相关的消息发送方法(如 interaction.response.send_message()),而你使用的 interaction.channel.send() 是向频道发送普通公共消息的方法,本身不支持这个参数,因此抛出错误。

另外,临时消息(仅触发交互的用户可见)只能通过交互响应/后续跟进方法实现,直接调用频道发送方法无法生成临时消息。

解决方案

根据你的需求,替换为交互响应方法即可:

情况1:首次响应交互(未发送过任何响应)

使用 interaction.response.send_message(),保留所有参数:

await interaction.response.send_message(
    f'<@{interaction.author.id}>',
    embed=embed,
    components=[
        Button(label='News', custom_id="button-give-news", style=ButtonStyle.grey),
        Button(label='Media', custom_id="button-give-media", style=ButtonStyle.red)
    ],
    ephemeral=True
)

情况2:已发送过交互响应(比如之前调用过 interaction.response.defer())

使用 interaction.followup.send() 发送后续临时消息:

await interaction.followup.send(
    f'<@{interaction.author.id}>',
    embed=embed,
    components=[
        Button(label='News', custom_id="button-give-news", style=ButtonStyle.grey),
        Button(label='Media', custom_id="button-give-media", style=ButtonStyle.red)
    ],
    ephemeral=True
)

补充说明

  • interaction.channel.send() 发送的消息会对频道内所有成员可见,不存在临时消息的设置项;
  • 只有通过 interaction.response 或 interaction.followup 系列方法发送的消息,才能通过 ephemeral=True 标记为仅触发交互的用户可见。

内容的提问来源于stack exchange,提问作者Felace

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 16:45:33