Skip to content

Commit

Permalink
Merge pull request #3 from dank074/patch
Browse files Browse the repository at this point in the history
Improve usage with discord.js-selfbot-v13
  • Loading branch information
dank074 authored Mar 29, 2023
2 parents 8abe465 + 50f9278 commit 078896c
Show file tree
Hide file tree
Showing 17 changed files with 2,091 additions and 1,689 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ What I implemented and what I did not.
- [X] Figure out rtp header extensions (discord specific) (discord seems to use one-byte RTP header extension https://www.rfc-editor.org/rfc/rfc8285.html#section-4.2)

## Usage
Install the package:
Install the package, alongside its peer-dependency discord.js-selfbot-v13:
```
npm install @dank074/discord-video-stream
npm install @dank074/discord-video-stream@latest
npm install discord.js-selfbot-v13@latest
```

Create a new streamer client:
Create a new client, and patch its events to listen for voice gateway events:
```typescript
const client = new StreamerClient();
import { Client } from "discord.js-selfbot-v13";
import "@dank074/discord-video-stream";

const client = new Client();
client.login('TOKEN HERE');

client.patchVoiceEvents();
```

Make client join a voice channel and create a stream:
Expand Down
1,757 changes: 1,567 additions & 190 deletions example/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@dank074/discord-video-stream": "file:..",
"@dank074/discord-video-stream": "2.0.0",
"discord.js-selfbot-v13": "^2.12.1",
"puppeteer": "^19.7.2",
"puppeteer-stream": "^2.1.4"
},
Expand Down
19 changes: 12 additions & 7 deletions example/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { StreamerClient, command, streamLivestreamVideo, VoiceUdp, streamOpts } from "@dank074/discord-video-stream";
import { Client } from "discord.js-selfbot-v13";
import { command, streamLivestreamVideo, VoiceUdp, setStreamOpts, streamOpts } from "@dank074/discord-video-stream";
import { launch, getStream } from 'puppeteer-stream';
import config from "./config.json";
import { Readable } from "stream";
import { executablePath } from 'puppeteer';

const client = new StreamerClient();
const client = new Client();

streamOpts.bitrateKbps = config.streamOpts.bitrateKbps;
streamOpts.fps = config.streamOpts.fps;
streamOpts.hardware_encoding = config.streamOpts.hardware_acc;
streamOpts.height = config.streamOpts.height;
streamOpts.width = config.streamOpts.width;
client.patchVoiceEvents(); //this is necessary to register event handlers

setStreamOpts(
config.streamOpts.width,
config.streamOpts.height,
config.streamOpts.fps,
config.streamOpts.bitrateKbps,
config.streamOpts.hardware_acc
)

// ready event
client.on("ready", () => {
Expand Down
Loading

0 comments on commit 078896c

Please sign in to comment.