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

查看:60
本文介绍了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 + '
';
  }

})

推荐答案

根据最新稳定文档,您可以使用 user.email 从用户帐户中检索电子邮件.鉴于您在代码中的任何地方都没有使用电子邮件,所以我不确定您在有人可以帮助我编写代码"时要问什么.不过,我将提供一个关于如何检索值的示例.

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天全站免登陆