discord.js
discord.js copied to clipboard
Deno Support
Which application or package is this feature request for?
discord.js
Feature
Deno, which is a Node.js successor, is a very popular runtime for JavaScript and TypeScript, while I know that most people still use Node.js as its the "industry standard" I also think DJS should add Deno support as it would be pretty easy - I'm not sure, I'm not an expert - and Deno also released NPM package support a long time ago, which would further help here.
I'm pretty sure this wouldnt require a new major version but more of a minor release, as its not that big of a thing imo, Deno is pretty close to how Node.js is and it should be pretty easy, I know lots of people also posted issues like this but I'm trying to get more into detail.
Ideal solution or implementation
To fix this I'd recommend trying to either make a new version of DJS on Denos package registery deno.land/x/ and/or adding support for Deno in the existing NPM library.
Alternative solutions or implementations
You could also simply iron out the bugs that Deno is facing with importing "npm:discord.js" and it would be basically kind of the same fix.
Other context
No response
### Tasks
- [ ] https://github.com/discordjs/discord.js/issues/9645
- [ ] https://github.com/discordjs/discord.js/issues/9666
Dupe of https://github.com/discordjs/discord.js/issues/7065 😄
Dupe of #7065 😄
I know, but that issue doesn't specifically mention how Deno has NPM support now and it would be way easier to implement without having to find other 3rd party libraries and packages.
Apparently Deno1.35 now supports discord.js along with some other NPM packages, however, it seems like undici is specifically not working on windows only.
After doing some testing, Deno works on the following systems:
- [ ] Windows
- [x] MacOS
- [x] Most Linux Distros
Here's a related issue: https://github.com/denoland/deno/issues/19766
check #9683
Should be closable now- no-de-no-de is merged, which will prevent this issue. Probably.
Nope, not fixed. 1.35.1's regression breaks compatibility anyway, and any version below 1.35.0 just returns an API error. :(
Try the @dev versions. That should work
@dev is what I'm using, silly.
Here's the error:
{
error: Error: Unexpected server response: 404
at HttpsClientRequest.<anonymous> (file:///C:/Users/[redacted]/AppData/Local/deno/npm/registry.npmjs.org/ws/8.13.0/lib/websocket.js:888:7)
at HttpsClientRequest.emit (ext:deno_node/_stream.mjs:1852:9)
at ext:deno_node/http.ts:476:18
at eventLoopTick (ext:core/01_core.js:182:11)
}
For now, a mitigation strategy is to deno upgrade --version 1.35.0 because that version is confirmed to work fine with Deno. I'll cherrypick through commits to see which one did this...
Noo, I see the issue. @dev builds haven't published yet, so the no-de-no-de branch isn't out on npm yet.
Aghhhhhhh! Why does it fail with a different error then?! Damn you, Deno and randomly breaking!
~~I'll just grab the file from CI and use that.~~
EDIT: Or you could just manually push dev, yeah, works too
Aha, no. It returns the EXACT SAME ERROR on [email protected]
Aha, no. It returns the EXACT SAME ERROR on [email protected]
hm so now the latest version of discord.js (when its published to npm) should fix the issue with Deno 1.35.0 and 1.35.1, right?
No, it's not fixed at all.
1.35.0 is fixed on npm:discord.js@dev (Windows), so use 1.35.0.
1.35.1 introduced a different regression that djs couldn't fix.
No, it's not fixed at all.
1.35.0 is fixed on
npm:discord.js@dev(Windows), so use 1.35.0. 1.35.1 introduced a different regression that djs couldn't fix.
well then when will we stop having to use @dev?
Once discord.js makes a new release
Once discord.js makes a new release
hm, ive tested both @dev and @latest, with deno 1.35.0 and 1.35.1 and all 4 of them seem to not work for now.
Im still getting the same abort error from undici timing out
are you sure you're on @dev? doesn't happen to me
are you sure you're on @dev? doesn't happen to me
yep, heres my code:
import { Client, GatewayIntentBits, Partials } from "npm:discord.js@dev";
import config from "./config.json" assert { type: "json" };
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
],
partials: [
Partials.Channel,
Partials.GuildMember,
Partials.Reaction,
Partials.ThreadMember,
Partials.User,
],
});
client.config = config;
client
.login(config.token)
.then(() => console.log(`🟩 [LOGIN] Client logged in.`))
// .catch((err) => console.error(`🟥 [LOGIN] ${err}`));
err:
at abort (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/api/abort-signal.js:10:18)
at AbortSignal.self.<computed> (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/undici/5.22.1/lib/api/abort-signal.js:29:5)
at innerInvokeEventListeners (ext:deno_web/02_event.js:792:7)
at invokeEventListeners (ext:deno_web/02_event.js:839:5)
at dispatch (ext:deno_web/02_event.js:696:9)
at AbortSignal.dispatchEvent (ext:deno_web/02_event.js:1101:12)
at AbortSignal.[[[signalAbort]]] (ext:deno_web/03_abort_signal.js:97:10)
at AbortController.abort (ext:deno_web/03_abort_signal.js:170:30)
at Timeout._onTimeout (file:///C:/Users/xash/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/1.7.1/dist/index.js:589:71)
at cb (ext:deno_node/internal/timers.mjs:60:31)
Deno 1.35.0, Windows 11 Lite (basically Tiny 11)
Not sure if W11 Lite is the problem. All I know is stock Windows 11 works fine.
Can you verify that the latest dev release is using fetch instead of undici for deno?
Can you verify that the latest dev release is using fetch instead of undici for deno?
well not in my case as you can clearly see undici in the error log, ill check the latest dev version tmr tho
Deno has pushed a commit to patch the regression in 1.35.1, next Deno release will be able to natively run discord.js.
For now, deno upgrade --canary will move you to the patched version of Deno.
For what it's worth, once we release new versions of all modules you also can do that 😄
Nope- it's not working for everyone on @dev. It seems to be local to 7xa5h- BUT some things use the Node ws module, which is unreliable on Deno to say the least.
Nope- it's not working for everyone on
@dev. It seems to be local to 7xa5h- BUT some things use the Nodewsmodule, which is unreliable on Deno to say the least.
do i close the issue now? i mean its practically fixed from both sides now