You need to enable JavaScript to run this app. 如何将Discord webhook发送的消息转发到另一个服务器?
优惠活动
大模型
产品
解决方案
定价
更多

如何将Discord webhook发送的消息转发到另一个服务器?

错误原因

你要转发的webhook消息内容全部存放在embed字段中,message.content(纯文本内容字段)本身为空,直接传入空值调用发送接口就会触发Cannot send an empty message的50006错误。

修复方案

你需要在发送时同时传入原消息的embed内容,示例代码如下:

@client.event
async def on_message(message):
    if message.webhook_id:
        target_channel = client.get_channel(760182149839716423)
        await target_channel.send(
            content = message.content,
            embeds = message.embeds,
            # 如果不需要转发附件可以删掉下面这一行
            files = [await attach.to_file() for attach in message.attachments]
        )
补充说明
  • 就算message.content为空,只要请求中包含embeds或files参数,就不会触发空消息校验错误
  • 请确保机器人拥有目标频道的「发送消息」「嵌入链接」权限,如果需要转发附件还要开通「上传附件」权限

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.07 20:54:03