(DISCORD.JS) 我该如何修复我的Discord“cmds”命令?

4
我想知道如何修复我的 "cmds" 命令?我似乎无法使它正常工作。它应该获取所有命令并将命令名称和描述添加到一个嵌入式窗口中,但实际上它显示了 这个错误 ,文件树在这里
module.exports = {
    name:'cmds',
    description:'Literally shows the commands thats it.',
    aliases:'',
    execute(client,msg,args,blacklisted){
        const fs = require('fs')
        const {MessageEmbed} = require("discord.js")
        const embed = new MessageEmbed()
        function getCommand(cmd){
            return client.commands.get(`${cmd}`)
       }
       const commandFiles = fs.readdirSync('.').filter(file => file.endsWith('.js'));
       for (const file of commandFiles){
        const command = require(`./${file}`)
        embed.addField(command.name,```${command.description}```)
        }
        const author = msg.author
        const user = msg.mentions.members.first() || msg.author;
        const useronly = msg.mentions.users.first()
        if (blacklisted.includes(author.id)){
            msg.reply(`You have been blacklisted from using this bot. if you think this is a mistake contact the bot owner.`)
        }else{
        embed.setTitle(`Commands`)
        embed.setColor('RANDOM')
        msg.reply({embeds : [embed] })
        }
    }
}
1个回答

0

我通过这种方式自己解决了它。

 function getCommand(cmd){
        return client.commands.get(`${cmd}`)
   }
   console.log(getCommand('avatar').name)
    const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
    for (const file of commandFiles){
        const command = require(`./${file}`)
        embed.addField(`${command.name}`,`\`\`\ ${command.description} \`\`\ `)
    }

console.log(getCommand('avatar').name) 是用于测试的。 - dimondflash57

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接