我想知道如何修复我的 "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] })
}
}
}
console.log(getCommand('avatar').name)
是用于测试的。 - dimondflash57