Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PAdventures opened this issue Oct 24, 2024 · 2 comments
Open

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

PAdventures opened this issue Oct 24, 2024 · 2 comments

Comments

@PAdventures
Copy link
Member

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
Copy link
Member

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.

catplvsplus added a commit that referenced this issue Oct 24, 2024
@PAdventures
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants