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

为什么Discord.js v13机器人@提及用户时无法触发ping通知?

问题根因

Discord.js v13 自定义allowedMentions配置时会覆盖默认的提及规则,你当前的代码仅开启了回复场景下的用户提及权限,没有配置允许普通内容中的用户提及,因此消息里的<@${message.author.id}>只会显示为提及文本,不会触发实际的ping提醒。

修复方案
  • 方案一:明确指定允许提及的用户ID列表
await message.guild.channels.cache
  .get(<SOME_ID>)
  .send({
    allowedMentions: { 
      repliedUser: true,
      users: [message.author.id]
    },
    content: `Welcome <@${message.author.id}> this is your channel`
  });
  • 方案二:配置允许的提及类型,适配所有同类型的提及
await message.guild.channels.cache
  .get(<SOME_ID>)
  .send({
    allowedMentions: { 
      repliedUser: true,
      parse: ["users"] // 允许所有用户提及,如有需要可追加"roles"、"everyone"
    },
    content: `Welcome <@${message.author.id}> this is your channel`
  });

注意:如果需要提及@everyone、@here或者角色,机器人需要在对应频道拥有Mention @everyone, @here, and All Roles权限,普通用户提及无需额外权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 04:45:03