![](/img/trans.png)
[英]Why is this .responseToString function saying that it isn't a function?
[英]Why does this keep saying it isn't a function?
const commandBase = require("./commands/command-base.js");
const readCommands = dir => {
const files = fs.readdirSync(path.join(__dirname, dir))
for (const file of files) {
const option = require(path.join(__dirname, dir, file))
commandBase(client, option);
console.log("Passed.");
}
}
基本上,尝试在 JavaScript 中创建我自己的 discord 机器人,当然使用Discord.js
。 但是有一个问题。 它一直说 commandBase 不是 function。 这甚至是 command-base.js 的一部分:
module.export = function(client, commandOptions) {
let {
commands,
expectedArgs = '',
permissionError = "You do not have permission to use or run that command.",
minArgs = 0,
maxArgs = null,
permissions = [],
callback
} = commandOptions;
if (typeof commands === 'string') {
commands = [commands];
}
我还尝试删除 function 并仅使用 =>,没有任何效果。 有谁知道为什么会这样? 它只是给出一个错误,说它不是 function。
你试过这个吗?
// command-base.js
export default function () {...}
// other js
import commandBase from "./commands/command-base.js"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.