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
lickm3
lickm3OP2y ago
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) => {
viztea
viztea2y ago
I assume you're using the queue plugin?
lickm3
lickm3OP2y ago
I will also send the code
lickm3
lickm3OP2y ago
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.
lickm3
lickm3OP2y ago
Yeah I do Tbh Iam really new to lavaclient
viztea
viztea2y ago
any reason you're using import and require in the same file? you should be able to use import with lavaclient
import "@lavaclient/queue/register";
import { SpotifyItemType, load } from "@lavaclient/spotify";
import { EmbedBuilder } from "discord.js";
import { Cluster } from "lavaclient";
import prettyMs from 'pretty-ms';
import "@lavaclient/queue/register";
import { SpotifyItemType, load } from "@lavaclient/spotify";
import { EmbedBuilder } from "discord.js";
import { Cluster } from "lavaclient";
import prettyMs from 'pretty-ms';
lickm3
lickm3OP2y ago
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 btw
viztea
viztea2y ago
Are you using ESM or CommonJS?
lickm3
lickm3OP2y ago
I think CommonJS
viztea
viztea2y ago
So replace the import syntax with require import {} from "package" -> const {} = require("package")
lickm3
lickm3OP2y ago
Well the errors are only on lines where I already use require
viztea
viztea2y ago
wait nvm you're using typescript
lickm3
lickm3OP2y ago
So maybe I use ESM? Iam not really sure. Iam still learning
viztea
viztea2y ago
ignore what i said
lickm3
lickm3OP2y ago
yeah
viztea
viztea2y ago
pretty-ms is purely an ESM module so you can't use it
lickm3
lickm3OP2y ago
Oh okay. Do you know about any alternative that supports typescript?
viztea
viztea2y ago
you can just downgrade actually do you use yarn or npm?
lickm3
lickm3OP2y ago
npm
viztea
viztea2y ago
npm install [email protected]
lickm3
lickm3OP2y ago
I installed the 7.0.1. Could I use require or import?
viztea
viztea2y ago
just retry starting your bot
lickm3
lickm3OP2y ago
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' ] }
viztea
viztea2y ago
make sure you've installed @lavaclient/spotify via npm install
lickm3
lickm3OP2y ago
Looks like its worked. Thanks for your time!
viztea
viztea2y ago
No problem :)
Want results from more Discord servers?
Add your server