尝试在Discord机器人上运行ban命令时,总是返回“内部服务器错误”

时间:2020-09-17 06:38:12

标签: discord discord.js

我尝试了多种格式化代码的方法,但是,每当我添加代码以便必须提供禁止某人的理由时,总是会收到内部服务器错误。这是我的代码。

module.exports.run = async (client, message, args) => {

  const member = message.mentions.members.first();
  const reason = args.slice(1).join(" ")

  if (!message.member.hasPermission("BAN_MEMBERS")) {
    return message.reply("you lack sufficiant permissions to execute this command.");
  } else if (member.hasPermission("ADMINISTRATOR")) {
    message.reply("you cannot ban this member.")
  }

  member.ban(reason).then((member) => {
    message.channel.send(`${member} has been banned.`);
  });

我使用命令处理程序,其他所有命令都可以正常工作。

2 个答案:

答案 0 :(得分:0)

第一步:定义用户

var data = [],
  totalPoints = 10;

function getRandomData() {

  if (data.length > 0) {
    data = data.slice(1);
  }
  // Do a random walk

  while (data.length < totalPoints) {
    var y;

    $.ajax({
      url: 'phpHelperDoc/get_live_data.php',
      type: 'POST',
      data: {
        authentication: "SN0000000004"
      },
      global: false,
      async: false,
      success: function(msgy) {
        var day_data = JSON.parse(msgy);
        y = day_data['value_1_live'];
        //Need to send this y value to var data=[];
      }
    });
    data.push(y);
  }
}

第二步:创建嵌入消息或普通消息

let user = message.mentions.members.first() || message.guild.members.cache.get(args.join(' '));

第三步:发送消息

const userbanned = new Discord.MessageEmbed()
        .setColor('#FF0000')
        .setAuthor('User Banned')
        .setDescription(`**${user.user.username}#${user.user.discriminator}** is now banned from this server`)
        .setFooter(`bot_name`);

答案 1 :(得分:-1)

尝试更改

member.ban().then((member) =>//

member.ban({reason : args.slice(1).join(' ')}).then((member) =>//