title: How to remove all roles and add one role on discord bot, and then remove the added role and restore previous roles
body: <p>I have a line of code for a discord bot to remove a specific named role and add a role named "muted" for a specific amount of time. Basically, the server can only have 3 roles, one that can issue the command, a "normal" rank with normal permissions, and then a "muted" role. and my code specifically removed the normal role and adds the muted role so they don't have any permissions. </p>
  
  <p>Well I added my bot onto another server with more than 3 roles, I decided to give everyone the normal role and also make the muted role. when I run the command, it works, but since the people have other roles, it allows then to continue speaking even though the muted role is at the top priority.</p>
  
  <p>My questions is that is there some code where I can just remove all their roles and add the muted role. and when the muted period is over, the muted role is removed and their previous roles are restored? here is my code below:</p>
  
  <pre><code> case 'mute':
  
      if(!message.member.roles.cache.find(r =&gt; r.name === "Admin")) return message.channel.send('You dont have permissions to do that you clown')
  
      let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]))
      if(!person) return message.reply("User Doesn't Exist");
  
      let mainrole = message.guild.roles.cache.find(role =&gt; role.name == "normal");
      let muterole = message.guild.roles.cache.find(role =&gt; role.name == "muted");
  
      if(!muterole) return message.reply("Role Doesn't Exist");
  
      let time = args[2];
  
      if(!time){
          return message.reply("How Long?");
      }
  
      person.roles.remove(mainrole.id);
      person.roles.add(muterole.id);
  
      message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`);
  
      setTimeout(function(){
          person.roles.add(mainrole.id);
          person.roles.remove(muterole.id);
          message.channel.send(`@${person.user.tag} has now been unmuted`)
      }, ms(time));
          break;
      case 'help':
          const embed2 = new MessageEmbed()
          .setTitle("How To Get Commands")
          .setColor(0x00fff7)
          .setDescription("Do /commands to get the list of commands");
  
          message.author.send(embed2);
          break;
  </code></pre>