如何让机器人提到频道? [英] How do I get a bot to mention a channel?

查看:166
本文介绍了如何让机器人提到频道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发表一条欢迎辞,但我似乎无法说出规则频道。我希望机器人说#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>";

这篇关于如何让机器人提到频道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆