Can't load subcommand

Hello, i'm trying to update to the latest djs and sapphire versions (from djs v13 and sapphire v3) and I have this structure for a subcommand where I have a file for each subcommand and a index where I declare and import them, before updating sapphire it searched all the files in the folder until it found the index, now it seems it only checks the first file (add) and doesn't load the subcommand correctly. Is there any way to fix this without having to change the structure and declare all the subcommands in one file? Error:
Error when loading '/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js': Error [EMPTY_MODULE]: A compatible class export was not found. [/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js]
at _LoaderStrategy.load (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/strategies/LoaderStrategy.mjs:63:13)
at async _CommandStore.loadPath (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:273:26)
at async _CommandStore.loadAll (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:185:24)
at async _CommandStore.loadAll (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+framework@5.1.0/node_modules/@sapphire/framework/dist/esm/lib/structures/CommandStore.mjs:39:5)
at async Promise.all (index 1)
at async _SapphireClient.login (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+framework@5.1.0/node_modules/@sapphire/framework/dist/esm/lib/SapphireClient.mjs:79:5) {
type: 'EMPTY_MODULE',
path: '/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js'
}
Error when loading '/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js': Error [EMPTY_MODULE]: A compatible class export was not found. [/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js]
at _LoaderStrategy.load (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/strategies/LoaderStrategy.mjs:63:13)
at async _CommandStore.loadPath (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:273:26)
at async _CommandStore.loadAll (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+pieces@4.2.2/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:185:24)
at async _CommandStore.loadAll (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+framework@5.1.0/node_modules/@sapphire/framework/dist/esm/lib/structures/CommandStore.mjs:39:5)
at async Promise.all (index 1)
at async _SapphireClient.login (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@sapphire+framework@5.1.0/node_modules/@sapphire/framework/dist/esm/lib/SapphireClient.mjs:79:5) {
type: 'EMPTY_MODULE',
path: '/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js'
}
No description
Solution:
That does not follow the structure for the command nor subcommand loader of sapphire or plugin-subcommands. If you want your subcommnands to be their own files with plugin-subcommands then 1. define them in the root command 2. import functions from other files 3. make sure those files start with a _ symbol (i.e. _add.ts) so sapphire skips them when loading 3. call those functions in the appropiate methods...
Jump to solution
2 Replies
Solution
Favna
Favna4mo ago
That does not follow the structure for the command nor subcommand loader of sapphire or plugin-subcommands. If you want your subcommnands to be their own files with plugin-subcommands then 1. define them in the root command 2. import functions from other files 3. make sure those files start with a _ symbol (i.e. _add.ts) so sapphire skips them when loading 3. call those functions in the appropiate methods
Vicente
Vicente4mo ago
Alright, thanks!