【问题标题】:Ban Command in Discord.js won't CompileDiscord.js 中的 Ban 命令无法编译
【发布时间】:2020-08-22 17:21:43
【问题描述】:

我有一个禁止用户的命令。我已经尝试将最后一部分更改为几个不同的变体,但如果我尝试 modChannel.message.send,它会抛出错误“modChannel 已定义”。我不知道还能做什么。


module.exports = {
  name: "ban",
  description: "Ban the troublesome users!",

  execute(message, args) {
        let member = message.mentions.user.first();
    if(!message.member.roles.some(r=>["Administrator"].includes(r.name))) {
      return message.channel.send("You don't have the permissions to use this command!");
    }
    if(!member.bannable) {
      return message.channel.send("I can\'t ban this person. Please try again. Make sure I have ban permissions.");
    }

    let reason = args.slice(7).join(" ");
    if(!reason) {
      reason = "No reason was provided.";
    }

    let modChannel = client.guilds.find(ch => ch.name === "mod-log");
    const banEmbed = {
      color: 225,
      title: "User Banned",
      description: `**User**: ${member.username}#${member.discriminator} (${member.id})
      **Reason**: ${reason}
      **Banned By**: ${message.author.username}#${message.author.discriminator}`,
    },

      modChannel.send({embed: banEmbed });
},
};

【问题讨论】:

  • 能否请您编辑完整的错误?

标签: discord.js


【解决方案1】:

试试:

let modChannel = message.guild.channels.find(c => c.name === "logs)

【讨论】:

    猜你喜欢
    • 2021-11-19
    • 1970-01-01
    • 2020-04-29
    • 2014-09-08
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多