I wonder if you can help (I search it and nothing...) I am learning how to work with discord.js node and I want to change my user nickname (not the username itself)
What it looks like is that you are trying to give your bot a nickname To change the bot's nickname use this:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
if (message.content.toLowerCase().startsWith('changeNick')) {
var newNickname = message.content.replace("changeNick ", "");
message.guild.me.setNickname(newNickname);
}
});
If you want to change a users nickname you should use this:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
let args = message.content.split(" ");
if(message.content.toLowerCase().startsWith("changeNick")){
if(!message.mentions.users.first()) return message.channel.send("You didn't specify a user!");
const user = message.mentions.members.first();
const username = message.guild.members.cache.find(userI => userI.id == user);
var newNickname = message.content.replace("changeNick "+args[1], "");
username.setNickname(newNickname);
}
});