1remove role discord.js
2
3const Role = message.guild.roles.cache.get("RoleID");
4Role.members.forEach((member, i) => { // Looping through the members of Role.
5 setTimeout(() => {
6 member.roles.remove(Role); // Removing the Role.
7 }, i * 1000);
8});
1case "suspend":
2 if (message.member.hasPermission('MANAGE_ROLES')) {
3 let rMember = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0])); //Gets the user
4 if (!rMember) return message.reply("That user does not exist.");
5 let gRole = message.guild.roles.find('name', 'SUSPENDED'); //Gets the SUSPENDED role
6
7 rMember.removeRoles(rMember.roles).then(console.log).catch(console.error); //Removes all roles
8 rMember.addRole(gRole.id); //Adds suspended Role
9
10
11 message.channel.send("User was suspended."); //Messages the channel that the user was suspended
12
13 try {
14 await rMember.send("You have been suspended."); //Tries to DM User
15 } catch (e) {
16 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
17 }
18
19
20 } else {
21 message.channel.send("You do not have permission to use this command.");
22 }
23 break;
24