From b1281a3e45832c6509e3a6a0b639fe8fa165e1f8 Mon Sep 17 00:00:00 2001 From: Yaikava <83710104+Yaikava@users.noreply.github.com> Date: Mon, 1 May 2023 20:03:57 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20-=20docs:=20add=20deno=20example?= =?UTF-8?q?=20with=20gateway=20workaround=20(#3016)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website/docs/examples/deno.md | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 website/docs/examples/deno.md diff --git a/website/docs/examples/deno.md b/website/docs/examples/deno.md new file mode 100644 index 000000000..922dd6304 --- /dev/null +++ b/website/docs/examples/deno.md @@ -0,0 +1,38 @@ +--- +sidebar_position: 2 +sidebar_label: Using with Deno +--- + +# Using with Deno + +To be able to use Discordeno with Deno there is one workaround needed if you are using the gateway package. +We need to make Deno use the websocket from Deno instead of the one which is used in node, because the npm support in Deno cannot use our websocket correctly. + +To do it you can use a workaround provided here: https://nest.land/package/katsura/files/src/discordenoFixes/gatewaySocket.ts + +You would use it like this. + +```ts +import { load } from "https://x.nest.land/Yenv@1.0.0/mod.ts"; +// Import it like this. There might be a newer version of this fix later, but I would not expect much changes. +import { fixGatewayWebsocket } from "https://x.nest.land/katsura@1.3.9/src/discordenoFixes/gatewaySocket.ts"; +import { createBot } from "npm:@discordeno/bot@19.0.0-next.5c42bdd"; + +const env = await load({ + token: /[M-Z][A-Za-z\d]{23}\.[\w-]{6}\.[\w-]{27}/, +}); + + +const bot = createBot({ + token: env.token, + events: { + ready: (data) => console.log(`Shard ${data.shardId} ready`) + } +}); + +// Use this function with the gateway managerr +fixGatewayWebsocket(bot.gateway); + +await bot.start(); + +``` \ No newline at end of file