Class constructor _Listener cannot be invoked without 'new'

i just got the listener from the docs and now it's sending this warning
Error when loading 'D:\Gits\dqm-neo\src\listeners\ready.ts': TypeError: Class constructor _Listener cannot be invoked without 'new'
at new ReadyListener (D:\Gits\dqm-neo\src\listeners\ready.ts:23:42)
at _ListenerStore.construct (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:337:2)
at _ListenerStore.loadPath (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:366:5)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _ListenerStore.loadAll (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:257:17)
at async Promise.all (index 3)
at async _SapphireClient.login (D:\Gits\dqm-neo\node_modules\@sapphire\framework\src\lib\SapphireClient.ts:352:3)
Error when loading 'D:\Gits\dqm-neo\src\listeners\ready.ts': TypeError: Class constructor _Listener cannot be invoked without 'new'
at new ReadyListener (D:\Gits\dqm-neo\src\listeners\ready.ts:23:42)
at _ListenerStore.construct (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:337:2)
at _ListenerStore.loadPath (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:366:5)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _ListenerStore.loadAll (D:\Gits\dqm-neo\node_modules\@sapphire\pieces\src\lib\structures\Store.ts:257:17)
at async Promise.all (index 3)
at async _SapphireClient.login (D:\Gits\dqm-neo\node_modules\@sapphire\framework\src\lib\SapphireClient.ts:352:3)
Sapphire Framework
Creating your own listeners | Sapphire
Similar to what you learned in both Creating Commands and [Creating
Solution:
for those using next.js set your version on something different than es5 (i used es2016)
Jump to solution
8 Replies
DIQE
DIQEOP17mo ago
sapphire ^5.0.5 discordjs ^14.414.1 node v20.8.0 tsc v5.2.2
Lioness100
Lioness10017mo ago
Can you send your code? @doqe
DIQE
DIQEOP17mo ago
the tsconfig.json is just a normal nextjs config but modified to fit in with decorators
DIQE
DIQEOP17mo ago
this is the ready.ts file (yoinked from docs)
DIQE
DIQEOP17mo ago
and here's the client and express server
DIQE
DIQEOP17mo ago
i found out the error
Solution
DIQE
DIQE17mo ago
for those using next.js set your version on something different than es5 (i used es2016)
Favna
Favna17mo ago
Set it to es2022. Es5 is JavaScript of 2013, es2016 is well of 2016. It's super super old Also integrating sapphire within nextjs is asking for problems sooner or later. Sapphire and discordjs are no designed to run within a full stack framework.

Did you find this page helpful?