简体   繁体   中英

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.

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 ||).

If anyone could help it would be really appreciated!

You would need to fetch the user by their id then display their avatar

Replace <Client> with either bot or client

(depending on what you set up your Discord Client as)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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