Reputation: 15
I got an error when trying to set the nickname of a user
UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
I tested all variables with console log they're set as expected and the [prefix + "rename"] is recognize... Am I doing it wrong? ^^'
bot.on("message", msg => {
var renameID=[ChannelID]
var userID= msg.author;
var message = msg.content.split(' ');
var args = message.length
if (message[0] === prefix + "rename") {
if (msg.channel.id === RenameID){
if (args === 2){
msg.guild.member(userID).setNickname(message[1]);
msg.reply(" some text " + message[1]);
}
}
}
edit: the bot has admin rights on the server
Upvotes: 0
Views: 212
Reputation: 5174
In the guild's role settings, your bot's role is not above the role of the user you want to edit.
Once you change that, your code should work.
Upvotes: 1