“Discord.js Hapus setiap peran yang dimiliki pengguna” Kode Jawaban

Hapus Peran Peran.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);
});
Xabos

Discord.js Hapus setiap peran yang dimiliki pengguna

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;
Upset Unicorn

Jawaban yang mirip dengan “Discord.js Hapus setiap peran yang dimiliki pengguna”

Pertanyaan yang mirip dengan “Discord.js Hapus setiap peran yang dimiliki pengguna”

Lebih banyak jawaban terkait untuk “Discord.js Hapus setiap peran yang dimiliki pengguna” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya