繁体   English   中英

Discord.js 使用@person 和#channel 发送消息

[英]Discord.js sending message with @person and #channel

使用我的 discord 机器人,我正在尝试创建欢迎消息。 我得到了以下工作:

  • 有人加入时发送消息
  • 获取加入者的姓名

现在我遇到的问题是在该消息中使用 @ 或 # 。 我对消息使用以下代码:

const welcomeMessage = `Welcome @${member.user.username} to the server! Please look through the #:page_with_curl:rules and assign yourself a role at #:mortar_board:role-assignment`;

但我也试过:

Welcome @${member.user.username} to the server! Please look through the #📃rules and assign yourself a role at #🎓role-assignment

他们俩都不是我想让他们做的事。 我从这段代码中得到以下结果: 没有 @ 和 # 的蓝色轮廓的 bot 消息

你可以看到@MEE6和 2 通道 # 不是蓝色的,也不能点击。 但是当我复制全文时,将其传递并在聊天中发送它确实显示为蓝色。

我想要的结果是我复制、粘贴和发送时的结果。 也就是以下内容: 带有@和#蓝色轮廓的我的消息

这是更多的代码:

const welcomeChannel = client.channels.cache.get('738678076174630922');
const welcomeMessage = `Welcome @${member.user.username} to the server! Please look through the #📃rules and assign yourself a role at #🎓role-assignment`;

welcomeChannel.send(welcomeMessage)

我应该怎么做才能解决这个问题?

const welcomeMessage = `Welcome ${member}! Please look through the <#id-of-rules-channel-here> and assign yourself a role at <#id-of-role-assignment-channel-here>`

您可以自动嵌入 Discord 类,如频道和成员,如果您已经将它们存储在变量中(就像您对member所做的那样),或者您可以直接在文本中使用它们的 ID,格式为<#id>用于频道或<@id>为用户。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM