How do I get a bot to mention a channel?

妖精的绣舞 提交于 2019-12-05 14:41:35

You need to send a GuildChannel for the channel name to be clickable.
You can achieve this by finding the channel in guild.channels
This returns a Collection, which you can filter.
If you have an ID (easier):

var message = "Make sure to check the rules at " + 
  message.guild.channels.get('channelID').toString();

If you want find the channel by ID (might break if you have multiple channels with the same name):

var message = "Make sure to check the rules at " + 
  message.guild.channels.find(channel => channel.name === "rules").toString();

EDIT:

Much easier way: in Discord mention the channel and put a \ (backslash) before the channel name \#rules. You'll get something like <#channelID>.
Use that like this: var message = "Make sure to check the rules at <#channelID>";

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!