mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
2.0 KiB
2.0 KiB
@biscuitland/ws
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
Install (for node18)
npm install @biscuitland/ws
yarn add @biscuitland/ws
Example (GW proxy)
import { ShardManager } from '@biscuitland/ws';
import { DefaultRestAdapter } from '@biscuitland/rest';
import { GatewayIntents } from '@biscuitland/api-types';
import type { DiscordGetGatewayBot, DiscordReady } from '@biscuitland/api-types';
const intents = GatewayIntents.Guilds;
const token = 'your token goes here';
const rest = new DefaultRestAdapter({ token });
const gateway = await rest.get<DiscordGetGatewayBot>('/gateway/bot');
// gateway bot code ↓
const ws = new ShardManager({
gateway,
config: { intents, token },
handleDiscordPayload(shard, payload) {
if (payload.t === "READY") {
const data = payload.d as DiscordReady;
console.log("logged in as:", data.user.username);
console.log("shard: %d", shard.options.id);
}
},
});
await ws.spawns();