Error [UNLOADED_PIECE]: The piece 'ready' does not exist.

Hello ! On this code :
import { Listener } from "@sapphire/framework";

export class ReadyListeners extends Listener {
constructor(context, options) {
super(context, {
...options,
once: true,
});
}

async run(client) {
console.log("Are you readyy ?");
}
}
import { Listener } from "@sapphire/framework";

export class ReadyListeners extends Listener {
constructor(context, options) {
super(context, {
...options,
once: true,
});
}

async run(client) {
console.log("Are you readyy ?");
}
}
I have this error:
1|common | Error [UNLOADED_PIECE]: The piece 'ready' does not exist.
1|common | at _ListenerStore.resolve (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:207:15)
1|common | at _ListenerStore.unload (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:148:24)
1|common | at ReadyListeners.unload (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Piece.mjs:58:22)
1|common | at ReadyListeners._runOnce (file:///home/mathie/node_modules/@sapphire/framework/dist/esm/lib/structures/Listener.mjs:29:16) {
1|common | type: 'UNLOADED_PIECE'
1|common | }
1|common | Error [UNLOADED_PIECE]: The piece 'ready' does not exist.
1|common | at _ListenerStore.resolve (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:207:15)
1|common | at _ListenerStore.unload (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Store.mjs:148:24)
1|common | at ReadyListeners.unload (file:///home/mathie/node_modules/@sapphire/pieces/dist/esm/lib/structures/Piece.mjs:58:22)
1|common | at ReadyListeners._runOnce (file:///home/mathie/node_modules/@sapphire/framework/dist/esm/lib/structures/Listener.mjs:29:16) {
1|common | type: 'UNLOADED_PIECE'
1|common | }
When I remove once, it's working Why? Thanks!
Solution:
you can set a name for the events, so you can name them differently but you can set the "event" property the event you need still that way you can have multiple listeners for a single event...
Jump to solution
10 Replies
Mathias
MathiasOP8mo ago
(My file name is ready.mjs)
Favna
Favna8mo ago
over a year ago or so someone had a similar issue and we ended up fixing a bug but I can't recall what the cause was. For starters:
Spinel
Spinel8mo ago
1. Which version of @sapphire/framework are you using? 2. What's your file/folder structure? 3. Did you use the CLI to generate your bot? 4. What's your main (CJS) or module (ESM) property in package.json 5. Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts? - Did you remove your output folder and rebuild then try again? 6. Is your problem related to message commands? Did you add loadMessageCommandListeners to your SapphireClient options Remember that if you are new to @sapphire/framework it is important that you read the user guide.
Calypso
Calypso8mo ago
1) 5.0.7 2) It's :
- src
- module1
- commands
- listeners
- module2
- commands
- listeners
- module3
- commands
- listeners
index.mjs
- src
- module1
- commands
- listeners
- module2
- commands
- listeners
- module3
- commands
- listeners
index.mjs
3) No 4) It's my src/index.mjs 5) No, JS 6) No, re'lated to a listeners (I answer for Mathie, we work on the same bot)
Favna
Favna8mo ago
modular. Did you carefully follow the steps from https://sapphirejs.dev/docs/Guide/additional-information/implementing-a-discordpy-like-cog-system ? That is more than likely related.
Sapphire Framework
Implementing a discord.py like Cog system | Sapphire
Developer who come from the Python ecosystem may be familiar with the "[Cog]" system that discord.py has implemented.
Calypso
Calypso8mo ago
Yes! Others events work corectly Okay, I get it: it's because I already have another event ready on once, for another module. Can't I use two? I'll probably need to don't use once
Solution
KaydaFox
KaydaFox8mo ago
you can set a name for the events, so you can name them differently but you can set the "event" property the event you need still that way you can have multiple listeners for a single event
KaydaFox
KaydaFox8mo ago
it shoullddd work with "once" too yup, i just tested it and it works withh once
Calypso
Calypso8mo ago
It's ok for me, thank you!
Favna
Favna8mo ago
ah yeah that does it. Good that you got it figured out.
Want results from more Discord servers?
Add your server