message listeners stopped working in sapphire v4 on my bot
hi,
this is my listener code:
file structure is also same:
zeno/src/listeners/messageCreate.js
below messageCommandFinish
listener/event code also stopped working:
i dont see any breaking changes regarding listeners/events in sapphire migrating guide and this same code was working perfectly fine but stopped working after upgrading to sapphire v4 and I didnt need to make any changes to this code for migration. Is there anything I missed or doing wrong? pls lemme know if i need to provide any other info which i might have missed. if anyone can point me in right direction, I would be immensely thankful. 🙏🏽Solution:Jump to solution
Okay Vladdy found the problem @owoer
You forgot to call
super.onLoad()
in your onLoad
method
```js
onLoad() {...19 Replies
For starters why not use Events.MessageCreate
Anyway also remember the djs v14 migration. Not sure if they changed message stuff. Slash commands are the future mate.
ok I used the enum now, the strange thing is the listeners loads just fine on bot startup but the logic in run method does not fire
can you make a github repository with minimal code that has the bug reproduced? I'll need to dig deeper with debugging.
ok sure, thanks for helping ^^
one weird thing i observed is that i use coc-tsserver for intellisense and it shows autocompletion for
onLoad
but doesnt show any tab completion for run methoda neovim user that uses raw JS instead of TS. Now there is a combination that's new to me.
anyway https://github.com/sapphiredev/framework/blob/main/src/optional-listeners/message-command-listeners/CoreMessageCreate.ts works just fine and that also has
run
😨 sorry about that, im still learning
i'll setup the minimal repro and come back when done, thank you for your time ^^
I mean I envy anyone who can really use vim. I only sometimes enable vscode-vim and even then I don't feel entirely comfortable.
fair enough :P
ok i made a minimal repro here : https://github.com/o-wo/sapphire-v4-messageCreate-event-minimal-repro
I have tested on separate test bot with required intents enabled on dashboard and it gives same results, the code is kinda ugly (sorry about that, still noob and learning js from free time after school) >.<
Ok
i'm looking into this now
Solution
Okay Vladdy found the problem @owoer
You forgot to call
super.onLoad()
in your onLoad
method
oh interesting, it works after adding that, thank you
is it a breaking change in sapphire V4? since on sapphire 3.x i never had to call that super function and listeners worked fine.
No, that code has been unchanged since probs sapphire v2
I seriously doubt it worked for you before that too
it really did xd
and they probably worked because you never overrode onLoad
onLoad handles the actual registering of the listener on the emitter
that makes sense, sorry for the hassle
No stress
At least it was an easy fix
I'll mark this as solved 😅
:D