无法读取未定义的属性“执行”

2024-03-15

我有一个脚本,如果命令正确,它将运行另一个脚本,但它会返回that https://i.stack.imgur.com/TO4xH.png

这是代码 获取文件的代码

const fs = require("fs");
const { settings } = require("cluster");
Client.commands = new Discord.Collection
const commandFiles = fs.readdirSync("./Commands/").filter(file => file.endsWith(".js"));

for(const file of commandFiles){
const command = require(`./Commands/${file}`);
Client.commands.set(command.name, command);
}

命令代码

    if (command == "setup"){
    Client.commands.get("setup").execute(message,args,prefix);
}

设置命令

const Discord = require("discord.js")
const db = require("quick.db")

module.exports = {
name: "Setup",
desc: "Main command to setup the bot",
execute(message, args, prefix){
    const ma = message.author.id

    const embed = new Discord.MessageEmbed()
    .setTitle("Setup bot - " + message.guild.name)
    .setDescription("Here you can setup the bot to do the main things")
    .setColor("#2163D7")
    .addFields(
        { name: '`!moderation`', value: '**Activate moderation features**'},
    )
    .setFooter("Do " + "`" + prefix + "`" + "setup before the command")
    message.channel.send(embed);
   if(message.member.permissions.has("ADMINISTRATOR")){
      message.channel.awaitMessages(ma, { max: 5, }).then(setup => {
        if(args[1] === "moderation"){
            db.set(`setup_moderations_${message.guild}`, true)
          }
      });


   }
}
}

以及我的命令是如何组织的

here https://i.stack.imgur.com/p9GYi.png

谢谢您的帮助


在我看来,问题可能与字体大小写有关。

你有name: 'Setup'(大写“S”)在您的模块中定义。 但是您正在尝试通过键访问该值Client.commands.get("setup")(小写的“s”),因此该集合没有这样的标识符

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法读取未定义的属性“执行” 的相关文章

随机推荐