DF
Dimensional Funlickm3
nodeTrackStart and nodeQueueFinish is not assignable to parameter of type 'keyof ClusterEvents'.
Hello. Iam developing discord music bot and I have problem with handler.
L
lickm3•330d 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) => {
V
viztea•330d ago
I assume you're using the queue plugin?
L
lickm3•330d ago
I will also send the code
L
lickm3•330d 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.
L
lickm3•330d ago
Yeah I do
Tbh Iam really new to lavaclient
V
viztea•330d ago
any reason you're using import and require in the same file?
you should be able to use import with lavaclient
L
lickm3•330d 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 btwV
viztea•330d ago
Are you using ESM or CommonJS?
L
lickm3•330d ago
I think CommonJS
V
viztea•330d ago
So replace the import syntax with require
import {} from "package"
-> const {} = require("package")
L
lickm3•330d ago
Well the errors are only on lines where I already use require
V
viztea•330d ago
wait nvm you're using typescript
L
lickm3•330d ago
So maybe I use ESM? Iam not really sure. Iam still learning
V
viztea•330d ago
ignore what i said
L
lickm3•330d ago
yeah
V
viztea•330d ago
pretty-ms is purely an ESM module so you can't use it
L
lickm3•330d ago
Oh okay. Do you know about any alternative that supports typescript?
V
viztea•330d ago
you can just downgrade actually
do you use yarn or npm?
L
lickm3•330d ago
npm
V
viztea•330d ago
npm install pretty-ms@7.0.1
L
lickm3•330d ago
I installed the 7.0.1. Could I use require or import?
V
viztea•330d ago
just retry starting your bot
L
lickm3•330d 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'
]
}
V
viztea•330d ago
make sure you've installed
@lavaclient/spotify
via npm install
L
lickm3•330d ago
Looks like its worked. Thanks for your time!
V
viztea•330d ago
No problem :)
129Members
View on DiscordWant results from more Discord servers?
More Poststhe bot keeps disconnecting while playingif I play a song after a while it get skipped or the bot disconnect in the middle of the song, even can you set the volume by default.when you create player for the first time using /play command for example is there's anyway to set tDiscussion ThreadsHello!Project DiscussionA thread for discussing KyuTranslationsForum discussing Kyu TranslationsDifference between pause(false) and resume()What's the difference between pause(false) and resume()?Any way to reconnect when node restartsI'm currently using the reconnect: { basic: whatever } property in my nodes. While this works whenevtrackEnd event isn't fired after bot is dc'd and rejoinsFor some reason the trackEnd event isn't fired in lavadeno if the bot was manually disconnected (by