discord.js提取电子邮件 [英] discord.js extracting emails

查看:69
本文介绍了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.

这篇关于discord.js提取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆