简体   繁体   English

Discord.js 使用 ID 而不是提及?

[英]Discord.js using ids instead of mentions?

So, I've recently started developing a bot for a server that I staff in however I can't get the bot to use IDs instead of mentions.所以,我最近开始为我工作的服务器开发一个机器人,但是我无法让机器人使用 ID 而不是提及。

For mentions, I have been using message.mentions.users.map but I don't know how I can make it so it also accepts IDs (Using ||).对于提及,我一直在使用message.mentions.users.map但我不知道如何制作它,因此它也接受 ID(使用 ||)。

If anyone could help it would be really appreciated!如果有人可以提供帮助,将不胜感激!

You would need to fetch the user by their id then display their avatar您需要通过他们的 id 获取用户,然后显示他们的头像

Replace <Client> with either bot or client<Client>替换为机器人客户端

(depending on what you set up your Discord Client as) (取决于您将 Discord 客户端设置为什么)

const target = <Client>.users.fetch('ID goes here')
message.channel.send(target.displayAvatarURL())

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

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