skip to Main Content

displayName will return the nickname if set in the guild (server), or the username If there is no nickname in the guild (server).

module.exports = {
    name: 'ping',
    execute(client, msg, args) {
        msg.reply(`Hello ${msg.member.displayName}`)
    }
}

How can i get nickname of user from User Profile? not guild (server).

2

Answers


  1. I’m assuming you are referring to the global display name (The Display Name set in Account Settings), which can be accessed like this:

    msg.reply(`Hello ${msg.author.displayName}`)
    

    See:
    Message.author

    User.displayName

    User object (Discord’s documentation about users, this explains which field is what a bit better)

    Login or Signup to reply.
  2. You can get global display name with this code:

    msg.reply(`Hello ${msg.member.user.globalName}`)
    

    the msg.member.user.globalName will get Display Name of user from User Profile (Account Settings)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search