javascript - Getting username from GuildMember - Stack Overflow

When I was coding a guildMemberAdd and a guildMemberRemove I ran across an issue... So, I was wondering

When I was coding a guildMemberAdd and a guildMemberRemove I ran across an issue... So, I was wondering, how do you obtain the user's username and discriminator from when they join? as when I tried member.username and member.discriminator it logs as undefined and undefined Code below, nothing was printed to console upon this issue:

exports.run = (client, member) => {
  member.guild.channels.find(`name`, `mod-logs`).send({embed: {
    "color": 8311585,
    "footer": {
      "text": "Bot made by: Pawxeric#0858"
    },
    "author": {
      "name": "New Member",
      "icon_url": member.avatarURL
    },
    "fields": [
      {"name": `${member.username}#${member.discriminator}`, // logs as undefined#undefined
      "value": "Joined"}
    ]
  }});
}

Also, the code is having issues picking up anything that uses the member value. Like avatarURL, username, and discriminator. If there's something I'm missing, please share down below :3c

When I was coding a guildMemberAdd and a guildMemberRemove I ran across an issue... So, I was wondering, how do you obtain the user's username and discriminator from when they join? as when I tried member.username and member.discriminator it logs as undefined and undefined Code below, nothing was printed to console upon this issue:

exports.run = (client, member) => {
  member.guild.channels.find(`name`, `mod-logs`).send({embed: {
    "color": 8311585,
    "footer": {
      "text": "Bot made by: Pawxeric#0858"
    },
    "author": {
      "name": "New Member",
      "icon_url": member.avatarURL
    },
    "fields": [
      {"name": `${member.username}#${member.discriminator}`, // logs as undefined#undefined
      "value": "Joined"}
    ]
  }});
}

Also, the code is having issues picking up anything that uses the member value. Like avatarURL, username, and discriminator. If there's something I'm missing, please share down below :3c

Share Improve this question edited Jul 19, 2018 at 1:29 Federico Grandi 6,7865 gold badges33 silver badges51 bronze badges asked Jul 18, 2018 at 21:48 PersikPersik 2755 gold badges11 silver badges20 bronze badges 1
  • Are you sure that member.guild.channels.find(`name`, `mod-logs`) is returning something? Also, you don't need backticks " ` " here because you aren't utilizing variables. You might as well use double quotes. – zero298 Commented Jul 18, 2018 at 22:24
Add a ment  | 

1 Answer 1

Reset to default 5

I think you want to get properties from a user object

<member>.user

User has username, discriminator and avatarurl.

The full object can be found on https://discord.js/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744228424a4564122.html

相关推荐

  • javascript - Getting username from GuildMember - Stack Overflow

    When I was coding a guildMemberAdd and a guildMemberRemove I ran across an issue... So, I was wondering

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信