使用discord js v14 Ping 角色

问题描述 投票:0回答:1

我正在尝试使用discord.js ping 一个角色;不仅显示角色名称,还向具有该角色的所有成员发送通知。

我已经尝试过了

await interaction.reply({
  embeds: [embed],
  components: [row],
  content: `<@&${team.id}>`,
  allowed_mentions: {
    roles: [`${team.id}`]
  }
});

我不知道我是否必须将“allowed_mentions”放在不同的地方,或者只是不使用它。也许是我没有正确使用它。

我也尝试过查看我的 Discord 设置。我将我的角色设置为所有人均可 ping 通,允许机器人对所有人进行 ping 操作,并允许分配给机器人的角色对所有人进行 ping 操作,但没有任何变化。

javascript node.js discord discord.js
1个回答
0
投票

在响应交互时您不能提及其他用户或角色,并且我不认为有任何方法可以覆盖此行为。您必须先推迟 Discord 的交互,然后将带有提及的消息内容作为消息发送到频道中。

await interaction.deferUpdate();
await interaction.channel.send({
  content: `<@&${team.id}>`,
  embeds: [embed],
  components: [row],
});

© www.soinside.com 2019 - 2024. All rights reserved.