繁体   English   中英

Discord.js - 如何将用户 ID 转换为会员

[英]Discord.js - How do I convert user ID to Member

我想知道如何将 ID 转换为会员。 我要转换的 ID 在 a.JSON 文件中。 我有这个脚本:

if(message.content == "!fl leaderboard") {
        embed = new Discord.MessageEmbed()
        const c = Object.entries(db).sort((a, b)=> b[1].level - a[1].level)
        for(const [key, value] of c) {
            embed.addField(db[message.author.id].tag, `Level: ${value.level} | XP: ${value.xp}`)
        }
        message.channel.send(embed)
    }


这就是它发布的内容: 在此处输入图像描述

关卡系统脚本为: https://hastebin.com/epucihenin.js

const User = client.users.cache.get("userid");
if (!User) return console.error("Couldn't find the user"); // Note that the user must be in a Guild with your bot for this to work.

console.log(`I found the user ${User.username}.`);

您可以使用guild.member()从用户 object 获取成员 object,您可以使用client.users.fetch()从 ID 获取用户 object。

。成员()

。拿来()

暂无
暂无

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

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