Advertisement
Donovan_DMC

ws.ts

Nov 4th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import WebSocket from "ws";
  2. import * as os from "os";
  3.  
  4. // this code is NOT how libraries do it, there is MUCH more to this, the gateway url must be fetched every time you launch a client, shards are automatically spawned, not manually filled in, etc
  5. const ws = new WebSocket("wss://gateway.discord.gg?v=6");
  6. ws
  7.     .on("message", (m) => {
  8.         console.log(m.toString());
  9.  
  10.         ws.send(JSON.stringify({
  11.             op: 2,
  12.             d: {
  13.                 token: "as if",
  14.                 properties: {
  15.                     $os: os.type(),
  16.                     $browser: "OwO",
  17.                     $device: "OwO"
  18.                 },
  19.                 compress: false,
  20.                 shard: [0, 1]
  21.             }
  22.         }));
  23.     })
  24.     .on("error", (e) => console.error(e))
  25.     .on("close", (e, r) => console.error("Unclean WS Close: %s %s", e, r));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement