Error using moonlink in deno
I'm trying to update my bot to use moonlink given issues I've been having with other libraries and I get the following error:
Any ideas on how to fix it?
20 Replies
I'm using the following code:
Deno's inbuilt Websocket doesn't support headers that's the reason you receive that error.
Options you have are:
- poly-fill the Global Websocket with some libraries like ws or others.
- use an unstable WebSocketStream API refer: https://questions.deno.com/m/1205621973657321534
- Wait for @1Lucas1.apk (better option ig)
Headers for WebSocket client - Deno
I need to connect Deno (as a client) to a WebSocket server that requires custom headers on connection. I can't seem to find any currently supported method to accomplish this since the
WebSocket
API only allows for the url
and protocols
parameters.
Is there any known best practice to accomplish this?I always forget about the stability of Deno and Bun
NO STABILITY, COMPATIBILITY
Welcome to JS Ecosystem.
How now for me it's 11h at night
Tomorrow morning, I do a search to better understand these problems
And I bring a solution
And also check the bun
It's 8:41 A.M for me and we're in the #help channel
here is 23:12
Sleep
Tomorrow, it is better, I think more clearly, with sleep is very bad
Have a good day for you and sorry for the delay of the solution
If you want to skip the direct solution of the package, you can find a package on the internet with webSocket working with headers, and put as a global until you do it in the package officially
Global polyfills don't work for my usecase because it breaks the discord api library im using, so unless there's a way I can only pass it to moonlink that doesn't work
You can do the following
import WebSocket from "npm:ws";
globalThis.WebSocket = WebSocket;
I'll see how I put it inside the package
or just declare
I will have to bring him back from the visa
I don't know how the moonlink internals look but maybe a solution to this could be a way to pass in your own websocket client when instanciating the manager for example?
GG @Bloxs, you just advanced to level 1!
then you provide a fix for this + don't add any extra deps
I presume you could probably also check for the deno namespace then use WebSocketStream but that feels more patchworky to me
npm install git+https://github.com/Ecliptia/moonlink.js.git#dev
GitHub
GitHub - Ecliptia/moonlink.js: MoonLink.js is a simple package for ...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. - GitHub - Ecliptia/moonlink.js: MoonLink.js is a simpl...
Try to install by Dev
I put WS again
Used Nodejs Global Websocket on V22
I know it'll work because I added the global npm import and that worked fine
I'll try it out though and see if smth diff happens
I've done it once, but then I was accused of plagiarism and so I removed from the package, now I make it possible not to do that
Getting accused of plagarism over allowing custom websocket implementations is crazy
They almost knocked the package because of this, nowadays they will not do that, but I do not do it
I tried it out and it works, interestingly enough it's also giving me faster song load/skip times than when I global polyfill but I assume that's probably just the lava node im using rather than code related
interesting
There's also one thing, I use global fetch, and it might be more efficient than Polly.