Custom Events not Creating Listeners
I'm having issues using Sapphire with custom events. For example, I have an event for when a member subscribes to a role:
Then, in another Sapphire listener:
My issue is that with custom named events, Sapphire doesn't seem to register all of them. For example, I'll have
guildMemberDemoted
, guildMemberPromoted
, guildMemberSubscribed
, and guildMemberUnsubscribed
.
guildMemberDemoted
will fire off, but guildMemberPromoted
does not. If I check the client for a guildMemberPromoted
listener, none exists.
I thought maybe I'd have to increase the max listeners for the client, but that also doesn't work.
Any ideas?Solution:Jump to solution
https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts
https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/guildMemberAdd.ts#L15
Custom events should work just fine. Make sure your emits are actually called and you do not have duplicate file names. By default the name of the file is used as the piece name, and the piece name has to be unique because we use a Map which has unique keys https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map...
3 Replies
Solution
https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts
https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/guildMemberAdd.ts#L15
Custom events should work just fine. Make sure your emits are actually called and you do not have duplicate file names. By default the name of the file is used as the piece name, and the piece name has to be unique because we use a Map which has unique keys https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
By default the name of the file is used as the piece name, and the piece nameOh! I didn't realize this! Despite them being in different directories, this is probably what's happening! I'll check and let you know! That was it. Thank you, @Favna!
FYI you can also add
name: 'whatever'
to those options if you dont want to change file names