Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove role discord.js

remove role discord.js

const Role = message.guild.roles.cache.get("RoleID");
Role.members.forEach((member, i) => { // Looping through the members of Role.
    setTimeout(() => {
        member.roles.remove(Role); // Removing the Role.
    }, i * 1000);
});
Comment

discord.js remove every role a user has

case "suspend":
  if (message.member.hasPermission('MANAGE_ROLES')) {
    let rMember = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0])); //Gets the user
    if (!rMember) return message.reply("That user does not exist.");
    let gRole = message.guild.roles.find('name', 'SUSPENDED'); //Gets the SUSPENDED role

    rMember.removeRoles(rMember.roles).then(console.log).catch(console.error); //Removes all roles
    rMember.addRole(gRole.id); //Adds suspended Role


    message.channel.send("User was suspended."); //Messages the channel that the user was suspended

    try {
      await rMember.send("You have been suspended."); //Tries to DM User
    } catch (e) {
      message.channel.send("We tried to DM the user to let them know, but their DM's are locked."); //Announces that their DMs are locked
    }


  } else {
    message.channel.send("You do not have permission to use this command.");
  }
  break;
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get date 
Javascript :: key value json javascript 
Javascript :: disable button in jsx 
Javascript :: dart code formatter vscode 
Javascript :: slice javascript string 
Javascript :: automatically select current date in date input javascript 
Javascript :: To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect 
Javascript :: json example 
Javascript :: puppeeter mac m1 
Javascript :: check if an array contains a string in javascript 
Javascript :: get version from package.json 
Javascript :: react native environment variables 
Javascript :: get closest parent tr table row jquery 
Javascript :: check if browser is internet explorer js 
Javascript :: js is boolean 
Javascript :: uploading file with fetch in js 
Javascript :: javascript string to variable 
Javascript :: how to calculate the time complexity of a recursive function 
Javascript :: react scroll 
Javascript :: how to format an integer with a comma in javascript 
Javascript :: jquery submit form 
Javascript :: instantiate template playcanvas 
Javascript :: get the most recent records in mongoose 
Javascript :: add li to ul javascript 
Javascript :: localstorage setitem 
Javascript :: find index in array javascript 
Javascript :: js hide div 
Javascript :: javascript text replace 
Javascript :: react case switch not working 
Javascript :: vue js default props 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =