javascript - 错误:ENOENT:没有这样的文件或目录,scandir './slash_commands'
问题描述
我真的坚持这一点,我已经有 V13 代码,我想添加我有的斜杠命令,但由于某种原因我无法通过这个,我找不到任何解释该做什么的东西。
如果有人可以帮我解决这个问题,将不胜感激。
code: const { readdirSync } = require("fs"),
ascii = require("ascii-table");
let table = new ascii("Commands");
table.setHeading("Slash Commands", "Load status");
module.exports = (client) => {
readdirSync("./slash_commands").forEach(dir => {
const commands = readdirSync(`./slash_commands/${dir}/`).filter(file => file.endsWith(".js"));
for (let file of commands) {
let pull = require(`../slash_commands/${dir}/${file}`);
client.slash_commands.set(pull.data.name, pull);
table.addRow(file, '✅');
if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
}
});
// Log the table
console.log(table.toString());
}
输出:
Error: ENOENT: no such file or directory, scandir './slash_commands'
at readdirSync (node:fs:1390:3)
at module.exports (C:\Users\codiene wrld\Desktop\dream\handlers\slash_command.js:8:9)
at Object.<anonymous> (C:\Users\codiene wrld\Desktop\dream\index.js:11:99)
解决方案
推荐阅读
- javascript - 在 nuxtjs 中将 @click 事件添加到 bootstrap4 下拉列表
- lua - 罗技 LUA 脚本
- wordpress - Flutter - wordpress 评论 + widget.post.title + widget.post.link 作为分享功能
- javascript - 无法使用 AudioContext 在 JavaScript 中发出声音
- database - 如何有效处理同一张表中的冷热数据?
- javascript - 混合面板 JQL | 参数累加器返回一个空数组
- r - 无法使用 terra 包将压缩的 geotiff 写入磁盘
- php - 如果使用准备好的语句,是否需要过滤/清理输入?
- node.js - 如何在频道中检查 Discord.js Bot 的权限?
- python - 按组对点进行指数拟合