0
votes

I made a command called callsign, when a user does it, they enter their callsign and the bot is supposed to put their callsign into their nickname, example;

!callsign 004

Then it changes their nickname from the one they had to 004 | nickname, for example;

AshieReflex > after command > 004 | AshieReflex

but what it does, it just returns undefined: 004 | undefined.

Here's my code

var nickname = message.content.split (" ").slice (1).join (" ");

if (message.content.startsWith (prefix + 'callsign')) {
    message.member.setNickname (`${nickname} | ${message.author.nickname}`);
}
2

2 Answers

1
votes

The user object does not have a nickname property. What you're looking for, instead, is the GuildMember object of the message's author - This can be collected using the member property of the Message object.

Quick suggestion: It is better to use the displayName property of the GuildMember object.

Final Code

var nickname = message.content.split (" ").slice (1).join (" ");
if (message.content.startsWith (prefix + 'callsign')) {
  message.member.setNickname (`${nickname} | ${message.member.displayName}`);
}
0
votes

message#author#nickname is not a function. What you're looking for is username

var nickname = message.content.split (" ").slice (1).join (" ");
if (message.content.startsWith (prefix + 'callsign')) {
  message.member.setNickname (`${nickname} | ${message.author.username}`);
}