[英](DISCORD.JS) how do i fix my discord "cmds" command?
我想知道如何修复我的“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] })
}
}
}
是../archive.js
不是./archive.js
archive.js 文件不在命令文件夹中,因此您不能使用./archive.js
我通过这样做自己解决了
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} \`\`\ `)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.