How do I insert emojis into a nickname in discord.js?

Tags: , , ,



Every time I try to do that, the emoji just changes into a question mark. Here’s my code:

client.on("message", async (msg) => {
    if (msg.content == "*verify check") {
        msg.member.setNickname(`${msg.member.displayName} ✅`);
        message.react(`✅`);
    }
});

Answer

Your message variable in the above code is inconsistent. You used ‘msg’ to catch the return value but used ‘message’ to react. Keep it consistent, otherwise, you might face errors. Also, a bot cannot change the nickname of the owner of the server, so if you want to test this code, make sure you are not the owner of the server where you are testing it.

bot.on('message', async message => {
    if (message.content == "*verify check") {
        message.member.setNickname(`${message.member.displayName} ✅`)
        .catch(err => console.log(err));
        message.react(`✅`);
    }
});


Source: stackoverflow