discord.js提取电子邮件
下面的代码使我可以获取有关用户的各种信息.但是,我找不到获取用户电子邮件的方法.是否已弃用?有人可以帮助我提供代码吗?
The code below lets me get every information about a user in discord. However, I couldn't find a way to get the emails of users. Is it deprecated? Can someone help me with the code?
client.on('ready', () => {
console.log(`logged in as ${client.user.username}`);
var Count;
for(Count in client.users.array()){
var User = client.users.array()[Count];
/* client.sendMessage(User, msg); */
//userName += User.username + "#" + User.discriminator + '\n';
}
})
According to the latest stable docs, you can use user.email to retrieve the Email from a user account. Seeing as you're not using email anywhere in you're code, I'm not sure what you're asking about when it comes to "can someone help me with the code". I will provide an example, however, on how to retrieve the value.
const email = client.user.email; // Will return null if no email is available.
根据我的测试,似乎Email变量仅显示给用户帐户,这意味着,如果您尝试检索机器人帐户的电子邮件,它将返回null.但是,如果您尝试检索其他用户的电子邮件,那不是Discord API提供的功能.
From my tests, it seems that the Email variable only shows up for user accounts, meaning if you're trying to retrieve the Email of a bot account, it will return null. If you're trying to retrieve the Email of other users, though, that is not a capability provided by the Discord API.