nodeTrackStart and nodeQueueFinish is not assignable to parameter of type 'keyof ClusterEvents'.
Hello. Iam developing discord music bot and I have problem with handler.
26 Replies
This is the errors:
src/handlers/lavaclient.ts:44:17 - error TS2345: Argument of type '"nodeTrackStart"' is not assignable to parameter of type 'keyof ClusterEvents'.
44 lavaclient.on("nodeTrackStart", (_node, queue, song) => {
~~~~~~~~~~~~~~~~
src/handlers/lavaclient.ts:77:17 - error TS2345: Argument of type '"nodeQueueFinish"' is not assignable to parameter of type 'keyof ClusterEvents'.
77 lavaclient.on("nodeQueueFinish", async (_node, queue) => {
I assume you're using the queue plugin?
I will also send the code
This is my code for lavaclient.ts: https://pastebin.com/MNLQ58zT
Pastebin
import { EmbedBuilder } from "discord.js";import { Cluster } from "...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Yeah I do
Tbh Iam really new to lavaclient
any reason you're using import and require in the same file?
you should be able to use import with lavaclient
let me try it
const pretty_ms_1 = __importDefault(require("pretty-ms"));
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\node_modules\pretty-ms\index.js from C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js not supported.
Instead change the require of index.js in C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js:8:37)
at Object.<anonymous> (C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\client\Client.js:33:20)
at Object.<anonymous> (C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\index.js:3:18) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v18.16.0
C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js:8:37 : const pretty_ms_1 = __importDefault(require("pretty-ms"));
C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\client\Client.js:33:20 : const lavaclient = require("../handlers/lavaclient");
C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\index.js:3:18 : const Client_1 = require("./client/Client");
This is after useing require btwAre you using ESM or CommonJS?
I think CommonJS
So replace the import syntax with require
import {} from "package"
-> const {} = require("package")
Well the errors are only on lines where I already use require
wait nvm you're using typescript
So maybe I use ESM? Iam not really sure. Iam still learning
ignore what i said
yeah
pretty-ms is purely an ESM module so you can't use it
Oh okay. Do you know about any alternative that supports typescript?
you can just downgrade actually
do you use yarn or npm?
npm
npm install [email protected]
I installed the 7.0.1. Could I use require or import?
just retry starting your bot
Error: Cannot find module '@lavaclient/spotify'
Require stack:
- C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js
- C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\client\Client.js
- C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\vitga\Desktop\workspace\DendaZMehoSklepa\dendazmehosklepa\build\handlers\lavaclient.js:6:35)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\vitga\\Desktop\\workspace\\DendaZMehoSklepa\\dendazmehosklepa\\build\\handlers\\lavaclient.js',
'C:\\Users\\vitga\\Desktop\\workspace\\DendaZMehoSklepa\\dendazmehosklepa\\build\\client\\Client.js',
'C:\\Users\\vitga\\Desktop\\workspace\\DendaZMehoSklepa\\dendazmehosklepa\\build\\index.js'
]
}
make sure you've installed
@lavaclient/spotify
via npm install
Looks like its worked. Thanks for your time!
No problem :)