久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 discord.js 獲取特定的會員用戶名

How to get specific member username with discord.js(如何使用 discord.js 獲取特定的會員用戶名)
本文介紹了如何使用 discord.js 獲取特定的會員用戶名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在嵌入消息中添加一個特定的成員信息(用戶名 + 頭像).有人知道怎么做嗎?

I would like to add one specific member information (username + avatar) into an embed message. Does someone know how to do that?

const feedback = new discord.RichEmbed()
.setColor([0, 0, 255])
.setFooter("Bot created by : " + message.author.username, message.author.avatarURL)
.setDescription("The text I want to be sent")

在上面的代碼中,我想通過特定的不和諧成員標識 id 更改message.author.username"和message.author.avatarUrl",例如:436577130583949315.

On the code above, I would like to change "message.author.username" and "message.author.avatarUrl" by a specific discord member identification id such as : 436577130583949315 for example.

但是我不知道從那個不和諧的識別號中能夠顯示用戶名和頭像的方式是什么.

However I don't know what is the way from that discord identification number to be able to show the username and the avatar.

提前感謝您的幫助:)

推薦答案

由于管理器的實現,必須修改以下代碼以使用最新版本的 Discord.js(本次編輯時為 v12).

您可以通過用戶的 ID 從客戶端的用戶緩存中檢索用戶,Client#users.但是,不能保證每個用戶都始終被緩存,因此您可以使用 Client#fetchUser().請記住,它返回一個 Promise.如果用戶在緩存中,該方法將返回它.

You can retrieve a user by their ID from the client's cache of users, Client#users. However, every user isn't guaranteed to be cached at all times, so you can fetch a user from Discord using Client#fetchUser(). Keep in mind, it returns a Promise. If the user is in the cache, the method will return it.

例子:

// Async context needed for 'await'

try {
  const devID = '436577130583949315';
  const dev = await client.fetchUser(devID);

  const feedback = new discord.RichEmbed()
    .setColor([0, 0, 255])
    .setFooter(`Bot created by ${dev.tag}.`, dev.displayAvatarURL)
    .setDescription('Your text here.');

  await message.channel.send(feedback);
} catch(err) {
  console.error(err);
}

這篇關于如何使用 discord.js 獲取特定的會員用戶名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 在线一区视频 | 久久国产一区二区三区 | 羞羞的视频免费观看 | 久久中文字幕一区 | 国产一区二 | 免费能直接在线观看黄的视频 | 亚洲成人免费在线 | 欧美成人免费在线视频 | 黄色av网站在线观看 | 国产美女久久 | 久久久日韩精品一区二区三区 | 亚洲精品视频在线播放 | 久久久久久久网 | 国产精品一区二区三区在线 | 日韩欧美在线视频 | 成人精品久久 | 无码一区二区三区视频 | 粉嫩国产精品一区二区在线观看 | 国产精品有限公司 | 久草成人 | 久久99精品久久久久久噜噜 | 欧美自拍一区 | 国产精品日韩欧美一区二区三区 | 亚洲黄色一级 | 日韩毛片在线视频 | 欧美天堂一区 | www..99re| 情侣酒店偷拍一区二区在线播放 | 欧美aaa| 亚洲午夜精品视频 | www.天天操.com | 国产精品揄拍一区二区 | 成人在线一区二区三区 | 午夜欧美一区二区三区在线播放 | 女朋友的闺蜜3韩国三级 | 激情网五月天 | 青青草一区 | 欧美成人a∨高清免费观看 色999日韩 | 国产成人jvid在线播放 | 日韩av第一页 | av在线免费观看网址 |