如何让机器人提到频道?
我正在发表一条欢迎辞,但我似乎无法说出规则频道。我希望机器人说#rules并制作它,以便你可以点击它去规则频道。我知道你可以和普通用户一起做这件事,但我想用我的机器人来做。每次我尝试,都不能像普通玩家一样点击。我已经尝试过#rules,< #channelID>和其他东西。它们都不是可点击的。
I am making a welcome message but I can’t seem to make it say the rule channel. I want the bot to say #rules and make it so you can click it to go to the rules channel. I know you can do this with a normal user, but I want to do it with my bot. Every time I try, it can’t be clicked like a normal player. I’ve tried doing #rules, <#channelID>, and other stuff. None of them are clickable.
您需要发送 GuildChannel
可点击的频道名称。
您可以通过在中查找频道来实现此目的.gild.channels
这将返回一个可以过滤的集合。
如果你有一个ID(更容易):
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();
如果您想按ID查找频道(如果您有多个同名频道,可能会中断) :
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();
编辑:
更简单的方法:在Discord中提及频道并在频道名称 \#之前加上
。您将获得类似 \
(反斜杠)规则< #passioID>
的内容。
使用如下: var message =确保检查<#channelID>上的规则;
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>";