【发布时间】:2019-08-12 11:32:14
【问题描述】:
我希望我们的 Discord Bot 提及特定频道,并使其可点击。我了解提及您使用用户 ID 的用户。我确实有频道 ID,只是不确定如何实现它。
【问题讨论】:
标签: discord discord.js
我希望我们的 Discord Bot 提及特定频道,并使其可点击。我了解提及您使用用户 ID 的用户。我确实有频道 ID,只是不确定如何实现它。
【问题讨论】:
标签: discord discord.js
您只需执行以下操作:
message.channel.send('Please take a look at this Discord Server channel <#CHANNELID>')
或者如果您从机器人获取频道 ID
const channel = message.guild.channels.find(channel => channel.name === 'Name of the channel');
message.channel.send(`Please take a look at this Discord Server channel <#${channel.id}>`)
然后这个频道就可以点击了,就像这个截图一样:
【讨论】:
很简单:^)
<#channel.id>
【讨论】:
Discord 上的频道在这里有这种特殊的语法:
<#channel id>
正如 Elitezen here 所评论的那样,在 Channel 上运行 toString() 可以为您做到这一点。然后,只需自己发送该字符串。这比手动操作要简单得多。
如果您正在回复消息,请像这样:
message.channel.send(message.channel.toString());
另外,就像其他人在这个问题中回答的那样,如果你愿意,你可以自己做。
如果你已经有一个 Channel 对象,你可以做这样的事情(想象你的频道被命名为myChannel - 但它不必被命名):
message.channel.send(`<#${message.channel.id}>`);
【讨论】: