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

1 messages · Page 1 of 1 (latest)

manic pecan
#

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 ?");
  }
}

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  | }

When I remove once, it's working
Why?

Thanks!

zinc bluffBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

manic pecan
#

(My file name is ready.mjs)

hardy kettle
#

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:

sly terraceBOT
#
  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?
  1. 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.

copper heart
#

(I answer for Mathie, we work on the same bot)

hardy kettle
copper heart
#

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

split cloak
#

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

#

it shoullddd work with "once" too

#

yup, i just tested it and it works withh once

copper heart
#

It's ok for me, thank you!

hardy kettle
#

ah yeah that does it. Good that you got it figured out.