thenorthsolution / Reciple

⚡Discord.js framework that just works
https://reciple.js.org
GNU General Public License v3.0
12 stars 1 forks source link

[BUG] - Config module exclude failing/not working as expected #68

Open PAdventures opened 1 month ago

PAdventures commented 1 month ago

Which package is this bug report for?

reciple

Issue description

Project folder structure

myproject /
├─ reciple.test.mjs
├─ reciple.mjs
├─ modules / -- compiled code
     ├─ db /
     └─ otherfolders /
└─ src /
     ├─ db /
     └─ otherfolders /

Error(s):

 ERROR  Reciple  10:29:04 : Failed to resolve module '/path/to/project/modules/db/schemas/alerts.js': ExpectedValidationError > s.instance(V)
 ERROR  Reciple  10:29:04 :   Expected a function for module .onStart
 ERROR  Reciple  10:29:04 : 
 ERROR  Reciple  10:29:04 :   Expected:
 ERROR  Reciple  10:29:04 :   | [Function: Function]
 ERROR  Reciple  10:29:04 : 
 ERROR  Reciple  10:29:04 :   Received:
 ERROR  Reciple  10:29:04 :   | undefined
 ERROR  Reciple  10:29:04 : 
 ERROR  Reciple  10:29:04 :     at _InstanceValidator.handle (file:////path/to/project/node_modules/@sapphire/shapeshift/dist/esm/index.mjs:1523:75)
 ERROR  Reciple  10:29:04 :     at _InstanceValidator.parse (file:////path/to/project/node_modules/@sapphire/shapeshift/dist/esm/index.mjs:964:90)
 ERROR  Reciple  10:29:04 :     at _RecipleModuleDataValidators.isValidOnStart (file:////path/to/project/node_modules/@reciple/core/dist/index.js:1551:113)
 ERROR  Reciple  10:29:04 :     at _RecipleModuleDataValidators.isValidRecipleModuleData (file:////path/to/project/node_modules/@reciple/core/dist/index.js:1564:34)
 ERROR  Reciple  10:29:04 :     at ModuleManager.resolveModuleFiles (file:////path/to/project/node_modules/@reciple/core/dist/index.js:1763:37)
 ERROR  Reciple  10:29:04 :     at async Command.<anonymous> (file:////path/to/project/node_modules/reciple/dist/commands/start.js:57:11)
 ERROR  Reciple  10:29:04 :     at async Command.parseAsync (/path/to/project/node_modules/commander/lib/command.js:1092:5)
 ERROR  Reciple  10:29:04 :     at async CLI.parse (file:////path/to/project/node_modules/reciple/dist/classes/CLI.js:114:9)
 ERROR  Reciple  10:29:04 :     at async file:////path/to/project/node_modules/reciple/dist/bin.js:3:1

Code sample

import  { CommandPermissionsPrecondition, CooldownPrecondition } from "reciple";
import { IntentsBitField } from "discord.js";

/**
 * @satisfies {import("reciple").RecipleConfig}
 */
export const config = {
    token: process.env.TEST_TOKEN ?? '',
    commands: {
        contextMenuCommand: {
            enabled: true,
            enableCooldown: true,
            acceptRepliedInteractions: false,
            registerCommands: {
                registerGlobally: true,
                registerToGuilds: []
            }
        },
        messageCommand: {
            enabled: true,
            enableCooldown: true,
            commandArgumentSeparator: ' ',
            prefix: '!'
        },
        slashCommand: {
            enabled: true,
            enableCooldown: true,
            acceptRepliedInteractions: false,
            registerCommands: {
                registerGlobally: true,
                registerToGuilds: []
            }
        }
    },
    applicationCommandRegister: {
        enabled: true,
        allowRegisterGlobally: true,
        allowRegisterToGuilds: true,
        registerEmptyCommands: true,
        registerToGuilds: []
    },
    client: {
        intents: [
            IntentsBitField.Flags.Guilds,
            IntentsBitField.Flags.GuildMembers,
            IntentsBitField.Flags.GuildMessages,
            IntentsBitField.Flags.MessageContent,
        ]
    },
    logger: {
        enabled: true,
        debugmode: true,
        coloredMessages: true,
        disableLogPrefix: true,
        logToFile: {
            enabled: true,
            logsFolder: './logs/development',
            file: 'latest.log'
        }
    },
    modules: {
        dirs: ['./modules/**/*'],
        exclude: [
            'halts',
            'preconditions',
            '_*',
            'BaseModule.js',
            'db'
        ],
        filter: file => true,
        disableModuleVersionCheck: false
    },
    preconditions: [
        new CooldownPrecondition(),
        new CommandPermissionsPrecondition(),
    ],
    cooldownSweeperOptions: {
        timer: 1000 * 60 * 60
    },
    checkForUpdates: true,
    version: `^9.7.1`
};

Versions

catplvsplus commented 1 month ago

It's a known problem when adding sub directories to an excluded folder. For now, you can fix this by defining your own exclude filter using the filter function at the module's config.

This is being fixed by changing the way excluded file patters were filtered. However old filter may not work after the changes.

PAdventures commented 1 month ago

It's a known problem when adding sub directories to an excluded folder. For now, you can fix this by defining your own exclude filter using the filter function at the module's config.

This is being fixed by changing the way excluded file patters were filtered. However old filter may not work after the changes.

Ah, ok. Thank you.