javascriptnode.jsdiscorddiscord.js

Resetting GuildMember's Nickname | Discord.JS


I'm trying to make a nickname resetter to your original nickname.

Example: !reset --> Resets your nickname.

This is the code I currently have:

if (message.content.startsWith(prefix)) return;
  switch (command) {

    case 'reset':
            
          


  };

Solution

  • case "reset":
        if (!message.member.nickname) return message.channel.send("You don't have any nickname set.");
        message.member.setNickname("").then(member => {
            message.channel.send("Your nickname has been reset.");
        }).catch(e => {
            console.log(e);
            message.channel.send("Couldn't reset your nickname.");
        })