@biscuitland/ws
TypeScript icon, indicating that this package has built-in type declarations

3.0.12 • Public • Published

@biscuitland/ws

Advice

This version of @biscuitland/ws is a fork of @discordeno/gateway, all credits go to them. However it has been heavily modified for proper use within biscuit.

Most importantly, biscuit's ws is:

A standalone gateway to interface Discord, it is meant to be used with a rest manager to send fetch requests to Discord

biscuit

Install (for node18)

npm install @biscuitland/ws
yarn add @biscuitland/ws

Example

import { ShardManager } from "@biscuitland/ws";
import { BiscuitREST, Router } from "@biscuitland/rest";
import { GatewayIntentBits } from "@biscuitland/common";

const intents = GatewayIntentBits.Guilds;
const token = "your token goes here";
const rest = new BiscuitREST({ token });
const api = new Router(rest).createProxy();

(async () => {
  const connection = await api.gateway.bot.get();

  // gateway bot code ↓
  const ws = new ShardManager({
    token,
    intents,
    connection,
    async handlePayload(shardId, payload) {
      console.log("Received payload on shard #%s", shardId, payload);
    },
  });

  await ws.spawnShards();
})();

Links

/@biscuitland/ws/

    Package Sidebar

    Install

    npm i @biscuitland/ws

    Weekly Downloads

    2

    Version

    3.0.12

    License

    Apache-2.0

    Unpacked Size

    78.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • drylozu
    • socram03
    • miia