为什么一直说这不是一个功能?

时间:2020-10-07 11:01:59

标签: javascript discord.js

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.");
        }
    }

基本上,当然,尝试使用Discord.js用JavaScript制作我自己的discord机器人。但是有一个问题。一直说commandBase不是一个函数。这甚至是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];
    }

我也尝试删除函数,仅使用=>,没有任何效果。有谁知道为什么会这样吗?它只是发出一个错误,说它不是一个函数。

1 个答案:

答案 0 :(得分:-1)

您尝试过吗?

// command-base.js
export default function () {...}

// other js
import commandBase from "./commands/command-base.js"