I have a discord bot that gets the nicknames of people, but nicknames do not seem to be exposed to me. The username is accessible however, the nickname is not:
client.on('interactionCreate', async interaction => {
var username = interaction.user.username; //accessible
I have also tried: interaction.member.displayName
and looked at options under interaction.user
however been unable to find something that allows me to get nicknames!
CodePudding user response:
If you look at the documentation you can see that to get a nickname you just need interaction.member.nickname
Note:
- Member may be null (for example if the interaction was not done in a guild, but in a DM)
.nickname
can be undefined as the member may not have a nickname