Error [EMPTY_MODULE]: A compatible class export was not found.

I'm trying to add code to the ready event that runs every "x" minutes. The code is a bit long and that's why I created a second file for the ready event. (Also, I want to have that separately.) I have everything that has to do with the function I want to implement in a folder called: "Extra: and inside you will have the index.js file (which will have the listener ready )and will have another file that will have "channels.js" where you will publish the function and a "functions.js" that will be in charge of making some canvas images. It would stay like this.
├── node_modules
├── package.json
└── src
├── commands
│ └── ping.js
├── index.js
└── listeners
└── ready.js
└── Extra
└── index.js
└── channels.js
└── functions.js
├── node_modules
├── package.json
└── src
├── commands
│ └── ping.js
├── index.js
└── listeners
└── ready.js
└── Extra
└── index.js
└── channels.js
└── functions.js
The problem is that it sends me an error in those 2 files. (channels.js and functions.js. I show you how the basic part of each file is.
Solution:
Prefix the file names with a _ Every file is expected to be a class export, unless it's skipped with a leading _ Alternatively move the folder out of the listeners folder...
Jump to solution
2 Replies
Kass507
Kass507OP6mo ago
index.js (extra):
const { Listener, Logger, container } = require('@sapphire/framework');
const sleep = require('util').promisify(setTimeout);
const schedule = require('node-schedule');
const {FortniteEventos } = require('./eventos');

class Fortnite extends Listener {
constructor(context, options = {}) {
super(context, {
...options,
event: 'ready', // Listen for the 'ready' event
});
}

async run(client) {
container.logger.info('Iniciando tareas de eventos...');
const cron = '*/1 * * * *';
const job = schedule.scheduleJob(cron, async function() {
container.logger.info('ejecutado a las: ' + new Date().toLocaleString());
job.cancel();
await FortniteEventos.reloadNoticias();
})
}
}

module.exports = {
Fortnite,
};
const { Listener, Logger, container } = require('@sapphire/framework');
const sleep = require('util').promisify(setTimeout);
const schedule = require('node-schedule');
const {FortniteEventos } = require('./eventos');

class Fortnite extends Listener {
constructor(context, options = {}) {
super(context, {
...options,
event: 'ready', // Listen for the 'ready' event
});
}

async run(client) {
container.logger.info('Iniciando tareas de eventos...');
const cron = '*/1 * * * *';
const job = schedule.scheduleJob(cron, async function() {
container.logger.info('ejecutado a las: ' + new Date().toLocaleString());
job.cancel();
await FortniteEventos.reloadNoticias();
})
}
}

module.exports = {
Fortnite,
};
channels.js
module.exports.Canales = Object.freeze({
tienda: "123456789",
noticiasbr: "123456789"
})
module.exports.Canales = Object.freeze({
tienda: "123456789",
noticiasbr: "123456789"
})
functions.js
const { SapphireClient, container } = require('@sapphire/framework');
const { Canales } = require('./canales');

module.exports.FortniteEventos = {
async reloadNoticias() {
const languageOrder = ['en', 'es', 'es-419']
//rest code
}
}
const { SapphireClient, container } = require('@sapphire/framework');
const { Canales } = require('./canales');

module.exports.FortniteEventos = {
async reloadNoticias() {
const languageOrder = ['en', 'es', 'es-419']
//rest code
}
}
Solution
Favna
Favna6mo ago
Prefix the file names with a _ Every file is expected to be a class export, unless it's skipped with a leading _ Alternatively move the folder out of the listeners folder
Want results from more Discord servers?
Add your server