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

如何让Discord机器人消息中的链接标记正常生效?

问题解答

问题原因

Discord对不同来源的消息采用不同的Markdown解析规则:

  • 临时交互消息(ephemeral)和Webhook发送的消息,会完整解析[文本](链接)这类Markdown链接格式;
  • 普通机器人通过channel.send()发送的消息,仅会自动识别纯URL为可点击链接,不会解析Markdown格式的链接语法。

解决方案

方案1:通过Webhook发送消息

Webhook发送的消息支持完整Markdown解析,效果和临时消息一致。可以先为频道创建Webhook,再用它发送内容:

// 创建频道Webhook(仅需执行一次,之后可复用Webhook URL)
const webhook = await channel.createWebhook({
  name: "链接推送机器人"
});

// 使用Webhook发送消息
await webhook.send({
  content: "links: [link1](https://example.com/1), [link2](https://example.com/2)"
});

如果已经有Webhook的URL,也可以直接用WebhookClient调用:

const { WebhookClient } = require('discord.js');
const webhookClient = new WebhookClient({ url: "你的Webhook地址" });

await webhookClient.send({
  content: "links: [link1](https://example.com/1), [link2](https://example.com/2)"
});

方案2:使用消息嵌入(Embed)

Embed的描述字段同样支持完整Markdown解析,也能实现目标效果:

const { EmbedBuilder } = require('discord.js');
const embed = new EmbedBuilder()
  .setDescription("links: [link1](https://example.com/1), [link2](https://example.com/2)");

await channel.send({ embeds: [embed] });

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 15:25:23