我该如何制作一个手动抓取它们的帮助命令



我正在尝试制作一个帮助命令,当您使用它时,不必手动键入所有命令,我该如何做到这一点?就像我一样!帮助实用程序如何获取实用程序文件夹,然后获取所有命令并列出它?我一直在尝试fs,但它与你如何获得导演混淆了。有什么帮助吗?

使用fs是正确的

const fs = require('fs')
// check if that folder exists
if (!fs.existsSync(`../../commands/${args[0]}`))
return message.channel.send('That folder does not exist');
// make array of all files within this folder
const files = fs.readdirSync(`../../commands/${args[0]})
for (const file of files) {
const command = require(`../../commands/${args[0]}/${file}`) // require the file
// now you can do whatever you want with it!
console.log(command.name, command.desription)
};

最新更新