Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Rhys
Rhys12/6/2022
Custom listener name not applying

Hey, I'm looking to put multiple listeners into the same file and I'm running into an issue where the name option isn't applying

As a quick reference, I am on the v14 PR although I believe it's unrelated


Debugging steps I've tried:

1. Initializing the name field in the constructor
2. Initializing the name field in a decorator
3. After the constructor, ignoring the read only warning and attempting to set name to a custom name

None of those have yielded successful results, when looking at it in a debugger and attempting to find the listener, it's using the file name

Looking at the source code for

https://github.com/sapphiredev/framework/blob/main/src/lib/structures/Listener.ts
and
https://github.com/sapphiredev/pieces/blob/main/src/lib/structures/Piece.ts

it seems like there's nothing that should be preventing this custom name from being applied but it isn't, any ideas on what might be causing this / further debugging steps?

Code:


export class SyncMessageDelete extends Listener {
  public constructor(context: Listener.Context, options: Listener.Options) {
    console.log(context, options);
    super(context, {
      ...options,
      event: "messageDelete",
      name: "MessageDeletedWatcher",
    });
  }

  public run(message: Message) {
    console.log("Deleting message: ", message.id);
  }
}


const sync_delete = bot.client.stores
      .get("listeners")
      .find((listener) => listener.name === "MessageDeletedWatcher"); // fails to find with this name



Debugger screenshot:

Solution Message

Rhys
Rhys12/6/2022
Looks like this was a caching issue with old files sticking around, not a bug
Ben855
Ben85512/6/2022
Out of curiosity and a bit off topic, why didn’t AO post the how to accept answers embed when this post was created?
Rhys
Rhys12/6/2022
It’s afraid of me and stays away
Rhys
Rhys12/6/2022
You better keep working or you’re going offline
Rhys
Rhys12/6/2022
In actuality I’m not sure, I’ll have to debug that but it should have been created
Rhys
Rhys12/6/2022
Rough guess is there may have been a long period of inactivity and some issue with the SQL connection so it didn’t get to check the server settings correctly - but nothing in the logs point to that
Ben855
Ben85512/6/2022
Ah that makes sense. I wasn’t sure if there was a way to opt out of getting those embeds if you already know how it works
Rhys
Rhys12/6/2022
I’m going to put a “Dismiss” button on them so if the thread owner presses that it’ll go away
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy