不和谐的机器人警告命令。机器人什么都不做

时间:2020-04-16 07:04:19

标签: javascript discord.js

我正在使用discord.js制作一个discord机器人,并且正在制作一个警告命令,当我使用它时什么也没发生。我可以帮忙吗?这是我的代码:

bot.on("message", message => {
  let args = message.content.substring(PREFIX.length).split(" ");

  switch (args[0]) {
    case "Warn":
      if (!message.member.hasPermission("LEADER" || "CO-LEADER"))
        return message.reply("You do not have the perms to warn");
      let wUser =
        message.guild.member(message.mentions.first()) ||
        message.guild.members.get(args[0]);
      if (!wUser) return message.reply("couldn't find that user");
      if (wUser.hasPermission("LEADER" || "CO-LEADER"))
        return message.reply("They waaaay to kewl");
      let reason = args.join(" ").slice(22);

      if (!warns[wUser.id])
        warns[wUser] = {
          warns: 0
        };

      warns[wUser.id].warns++;

      fs.writeFile("./warnings.json", JSON.stringify(warns), error => {
        if (error) {
          console.log(error);
        }
      });

      let warnEmbed = new Discord.RichEmbed()
        .setDescription("Warns")
        .setAuthor(message.author.username)
        .setColor("0x00BFFF")
        .addField("Warned User", `<@${wUser.id}>`)
        .addField("Warned In", message.channel)
        .addField("Number of Warnings", warns[wUser.id].warns)
        .addField("Reason", reason);

      let warnChannel = message.guild.channels.find(`name`, "warnings⚠");
      if (!warnChannel) return message.reply("could not find channel");

      warnChannel.send(warnEmbed);

      if (warns[wUser.id].warns == 2) {
        let muterole = message.guild.roles.find(`name`, "mute");
        let mainrole = message.guild.roles.find(`name`, "member");
        if (!muterole) return message.reply("we need to mute them");
        if (!mainrole) return message.reply("how are they here");

        let mutetime = "5h";
        wUser.addRole(muterole.id);
        wUser.removeRole(mainrole.id);
        message.channel.send(
          `${wUser.tag} has been muted for 5h due to too many warnings`
        );

        setTimeout(function() {
          wUser.addRole(mainrole.id);
          wUser.removeRole(muterole.id);
          message.reply("They have been unmuted");
        }, ms(mutetime));
      }

      if (warns[wUser.id].warns == 3) {
        message.guild.member(wUser).ban(reason);
        message.reply(`${wUser.tag} has been banned.`);
      }

      break;
  }
});

0 个答案:

没有答案