通过命令添加和删除 Discord 角色

时间:2021-06-20 15:13:09

标签: javascript discord roles

好吧,这里的问题可能很愚蠢,但我很困惑。

我正在尝试设置一个命令,以便在运行时添加和删除某些角色,例如: 添加 ID1、ID2、ID3 删除 ID4、ID5、ID6、ID7 显示“此用户设置为(ROLE),需要开工单更改”

我有以下文件,但不知道如何编辑它以自动选择某些角色,而不必手动应用它们:

const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {
  if (!message.member.permissions.has(["MANAGE_ROLES", "ADMINISTRATOR"]))
    return message.channel.send(
      "Sorry! :disappointed: :broken_heart: You don't have permission to perform this command!"
    );

  let rMember =
    message.mentions.members.first() ||
    message.guild.members.cache.find((m) => m.user.tag === args[0]) ||
    message.guild.members;
  let role =
    message.guild.roles.cache.find((r) => r.name == args[1]) ||
    message.guild.roles.cache.find((r) => r.id == args[1]) ||
    message.mentions.roles.first();
  if (!role)
    return message.channel.send(
      "Is this user a SS, SD, Sub or Dom?"
    );

  if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"]))
    return message.channel.send(
      "Sorry, friend :broken_heart: :shrug: I don't have permission to perform this command!"
    );

  if (rMember.roles.has(role.id)) {
    return message.channel.send(
      `$rMember.displayName), already has this role!`
    );
  } else {
    await rMember.roles.add(role.id).catch((e) => console.log(e));
    message.channel.send(
      `${rMember.displayName} is set as a Switch Sub and will need to open a ticket if they wish to change this`
    );
  }

  let embed = new Discord.MessageEmbed()
    .setColor(colours.redlight)
    .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL())
    .addField("Moderation:", "Member set as SS")
    .addField("Date:", message.createdAt);
    
  let sChannel = message.guild.channels.cache.find(
    (c) => c.name === "beans-the-frog"
  );
  sChannel.send(embedVariable);
};

module.exports.config = {
  name: "ss",
  description: "Sets a user as a (ROLE)",
  usage: "beans addrole",
  accessableby: "Staff Team",
  aliases: ["ss"],
};

0 个答案:

没有答案