lunibee 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/builders/commands.d.ts +1 -1
- package/dist/builders/components.d.ts +9 -11
- package/dist/builders/embed.d.ts +1 -1
- package/dist/builders/index.d.ts +1 -1
- package/dist/builders/index.js +87 -1298
- package/dist/builders/index.js.map +3 -11
- package/dist/chunks/index-0wn81eng.js +2492 -0
- package/dist/chunks/index-0wn81eng.js.map +17 -0
- package/dist/chunks/index-2en489j6.js +40 -0
- package/dist/chunks/index-2en489j6.js.map +10 -0
- package/dist/chunks/index-3hyps48a.js +203 -0
- package/dist/chunks/index-3hyps48a.js.map +11 -0
- package/dist/chunks/index-57c5n3ms.js +2274 -0
- package/dist/chunks/index-57c5n3ms.js.map +19 -0
- package/dist/chunks/index-5yx92e36.js +1170 -0
- package/dist/chunks/index-5yx92e36.js.map +14 -0
- package/dist/chunks/index-690bp093.js +95 -0
- package/dist/chunks/index-690bp093.js.map +10 -0
- package/dist/chunks/index-7fp2hvmg.js +2155 -0
- package/dist/chunks/index-7fp2hvmg.js.map +24 -0
- package/dist/chunks/index-cnmsajvk.js +1119 -0
- package/dist/chunks/index-cnmsajvk.js.map +12 -0
- package/dist/chunks/index-fdvgk2sw.js +1310 -0
- package/dist/chunks/index-fdvgk2sw.js.map +21 -0
- package/dist/chunks/index-gyvps8b9.js +214 -0
- package/dist/chunks/index-gyvps8b9.js.map +12 -0
- package/dist/chunks/index-jzg4bh99.js +1533 -0
- package/dist/chunks/index-jzg4bh99.js.map +21 -0
- package/dist/chunks/index-mgw2yvrm.js +3547 -0
- package/dist/chunks/index-mgw2yvrm.js.map +25 -0
- package/dist/chunks/index-yh76b55h.js +3449 -0
- package/dist/chunks/index-yh76b55h.js.map +29 -0
- package/dist/collection/index.js +9 -1118
- package/dist/collection/index.js.map +3 -6
- package/dist/core/api.d.ts +3 -3
- package/dist/core/channel-create.d.ts +2 -2
- package/dist/core/commands.d.ts +3 -3
- package/dist/core/events.d.ts +4 -4
- package/dist/core/handles.d.ts +4 -4
- package/dist/core/index.d.ts +25 -20
- package/dist/core/index.js +68 -10130
- package/dist/core/index.js.map +3 -65
- package/dist/core/permissions.d.ts +1 -1
- package/dist/core/redis-cache.d.ts +1 -1
- package/dist/formatters/index.js +41 -110
- package/dist/formatters/index.js.map +3 -4
- package/dist/handlers/index.js +5 -37
- package/dist/handlers/index.js.map +3 -4
- package/dist/index.d.ts +21 -21
- package/dist/index.js +641 -16325
- package/dist/index.js.map +3 -92
- package/dist/managers/advanced.d.ts +3 -3
- package/dist/managers/application.d.ts +2 -2
- package/dist/managers/base.d.ts +1 -1
- package/dist/managers/emoji.d.ts +2 -2
- package/dist/managers/guild-resources.d.ts +6 -6
- package/dist/managers/guild.d.ts +3 -3
- package/dist/managers/index.d.ts +4 -8
- package/dist/managers/index.js +51 -4060
- package/dist/managers/index.js.map +3 -29
- package/dist/managers/member.d.ts +2 -2
- package/dist/managers/message.d.ts +14 -6
- package/dist/managers/role.d.ts +2 -2
- package/dist/managers/thread.d.ts +3 -3
- package/dist/managers/user.d.ts +7 -4
- package/dist/rest/index.d.ts +10 -35
- package/dist/rest/index.js +57 -2184
- package/dist/rest/index.js.map +3 -18
- package/dist/rest/limiter.d.ts +9 -1
- package/dist/rest/webhook.d.ts +2 -8
- package/dist/sharding/bus.d.ts +2 -2
- package/dist/sharding/cluster.d.ts +45 -5
- package/dist/sharding/context.d.ts +45 -3
- package/dist/sharding/gateway-bot.d.ts +2 -1
- package/dist/sharding/health.d.ts +1 -1
- package/dist/sharding/identify.d.ts +12 -0
- package/dist/sharding/index.d.ts +44 -11
- package/dist/sharding/index.js +60 -4620
- package/dist/sharding/index.js.map +3 -33
- package/dist/sharding/supervisor.d.ts +4 -2
- package/dist/structures/audit-log.d.ts +1 -1
- package/dist/structures/base.d.ts +6 -6
- package/dist/structures/channels.d.ts +1 -1
- package/dist/structures/embed.d.ts +1 -1
- package/dist/structures/index.d.ts +14 -14
- package/dist/structures/index.js +109 -2382
- package/dist/structures/index.js.map +3 -16
- package/dist/structures/interactions.d.ts +13 -9
- package/dist/structures/options.d.ts +1 -1
- package/dist/structures/permissions.d.ts +2 -2
- package/dist/structures/resources.d.ts +10 -10
- package/dist/structures/sticker.d.ts +1 -1
- package/dist/types/gateway.d.ts +2 -79
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.js +41 -272
- package/dist/types/index.js.map +3 -6
- package/dist/utils/index.js +23 -209
- package/dist/utils/index.js.map +3 -5
- package/dist/voice/connection.d.ts +200 -0
- package/dist/voice/crypto.d.ts +50 -0
- package/dist/voice/dave.d.ts +85 -0
- package/dist/voice/effects.d.ts +31 -0
- package/dist/voice/emitter.d.ts +14 -0
- package/dist/voice/gateway.d.ts +59 -0
- package/dist/voice/index.d.ts +25 -228
- package/dist/voice/index.js +111 -442
- package/dist/voice/index.js.map +3 -4
- package/dist/voice/libopus.d.ts +88 -0
- package/dist/voice/networking.d.ts +80 -0
- package/dist/voice/ogg.d.ts +24 -0
- package/dist/voice/opus.d.ts +18 -0
- package/dist/voice/player.d.ts +79 -0
- package/dist/voice/protocol.d.ts +76 -0
- package/dist/voice/receiver.d.ts +59 -0
- package/dist/voice/resource.d.ts +102 -0
- package/dist/voice/udp.d.ts +40 -0
- package/dist/ws/close-codes.d.ts +1 -1
- package/dist/ws/index.d.ts +25 -4
- package/dist/ws/index.js +47 -1336
- package/dist/ws/index.js.map +3 -17
- package/dist/ws/protocol.d.ts +1 -1
- package/dist/ws/send-budget.d.ts +0 -2
- package/dist/ws/state.d.ts +0 -10
- package/package.json +19 -16
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Transport encryption modes this package implements. */
|
|
2
|
+
export type VoiceEncryptionMode = "aead_aes256_gcm_rtpsize" | "aead_xchacha20_poly1305_rtpsize";
|
|
3
|
+
/** Modes in order of preference: AES-GCM when the runtime has it, XChaCha20-Poly1305 always. */
|
|
4
|
+
export declare const SUPPORTED_ENCRYPTION_MODES: readonly VoiceEncryptionMode[];
|
|
5
|
+
/** Picks the first mode in our preference order that the voice server offers. @throws {VoiceError} If none is offered. */
|
|
6
|
+
export declare function chooseEncryptionMode(offered: readonly string[]): VoiceEncryptionMode;
|
|
7
|
+
/** A parsed RTP packet header. */
|
|
8
|
+
export interface RtpHeader {
|
|
9
|
+
version: number;
|
|
10
|
+
padding: boolean;
|
|
11
|
+
extension: boolean;
|
|
12
|
+
payloadType: number;
|
|
13
|
+
sequence: number;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
ssrc: number;
|
|
16
|
+
/** Bytes authenticated but not encrypted: the fixed header, CSRCs and the extension header. */
|
|
17
|
+
headerSize: number;
|
|
18
|
+
/** 32-bit words of extension data, encrypted with the payload. */
|
|
19
|
+
extensionWords: number;
|
|
20
|
+
}
|
|
21
|
+
/** Writes the 12-byte RTP header Discord expects for an outgoing Opus packet. */
|
|
22
|
+
export declare function rtpHeader(sequence: number, timestamp: number, ssrc: number): Uint8Array;
|
|
23
|
+
/** Parses an RTP header, or returns `undefined` for anything that is not a complete RTP v2 header. */
|
|
24
|
+
export declare function parseRtpHeader(packet: Uint8Array): RtpHeader | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Seals and opens RTP packets for one voice session ("rtpsize" AEAD modes):
|
|
27
|
+
* the RTP header (and extension header) is authenticated, the rest is
|
|
28
|
+
* encrypted, and a 32-bit nonce counter is appended to the packet. The full
|
|
29
|
+
* nonce is that counter followed by zeros (12 bytes for AES-GCM, 24 for
|
|
30
|
+
* XChaCha20-Poly1305).
|
|
31
|
+
*/
|
|
32
|
+
export declare class PacketCipher {
|
|
33
|
+
#private;
|
|
34
|
+
readonly mode: VoiceEncryptionMode;
|
|
35
|
+
/** @param counter First nonce counter (default 0). */
|
|
36
|
+
constructor(mode: VoiceEncryptionMode, key: Uint8Array, counter?: number);
|
|
37
|
+
/** The nonce counter of the next sealed packet (wraps at 2^32). */
|
|
38
|
+
get counter(): number;
|
|
39
|
+
/** Encrypts `payload` under `header`. @returns The datagram: header, ciphertext, tag, nonce suffix. */
|
|
40
|
+
seal(header: Uint8Array, payload: Uint8Array): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Decrypts a received datagram. Removes the encrypted extension data and
|
|
43
|
+
* RTP padding. @returns The header and the plaintext payload, or
|
|
44
|
+
* `undefined` when the packet is malformed or fails authentication.
|
|
45
|
+
*/
|
|
46
|
+
open(packet: Uint8Array): {
|
|
47
|
+
header: RtpHeader;
|
|
48
|
+
payload: Uint8Array;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** The parts of `@snazzah/davey`'s session this package uses. */
|
|
2
|
+
interface DaveyNativeSession {
|
|
3
|
+
readonly ready: boolean;
|
|
4
|
+
readonly voicePrivacyCode: string;
|
|
5
|
+
reinit(protocolVersion: number, userId: string, channelId: string): void;
|
|
6
|
+
reset(): void;
|
|
7
|
+
setExternalSender(data: Buffer): void;
|
|
8
|
+
getSerializedKeyPackage(): Buffer;
|
|
9
|
+
processProposals(operationType: number, proposals: Buffer, recognizedUserIds?: string[]): {
|
|
10
|
+
commit?: Buffer;
|
|
11
|
+
welcome?: Buffer;
|
|
12
|
+
};
|
|
13
|
+
processWelcome(welcome: Buffer): void;
|
|
14
|
+
processCommit(commit: Buffer): void;
|
|
15
|
+
encryptOpus(packet: Buffer): Buffer;
|
|
16
|
+
decrypt(userId: string, mediaType: number, packet: Buffer): Buffer;
|
|
17
|
+
canPassthrough(userId: string): boolean;
|
|
18
|
+
setPassthroughMode(passthrough: boolean, expirySeconds?: number): void;
|
|
19
|
+
}
|
|
20
|
+
/** The parts of `@snazzah/davey` this package uses. */
|
|
21
|
+
export interface DaveyModule {
|
|
22
|
+
DAVE_PROTOCOL_VERSION: number;
|
|
23
|
+
DAVESession: new (protocolVersion: number, userId: string, channelId: string) => DaveyNativeSession;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Loads `@snazzah/davey` (the DAVE protocol: MLS group keys and frame
|
|
27
|
+
* encryption), an optional peer dependency. @returns The module, or `null`
|
|
28
|
+
* when it is not installed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadDave(): Promise<DaveyModule | null>;
|
|
31
|
+
/** Highest DAVE protocol version available here: 0 when `@snazzah/davey` is not installed. */
|
|
32
|
+
export declare function maxDaveProtocolVersion(): Promise<number>;
|
|
33
|
+
/** What a {@link DaveSession} asks its connection to send. */
|
|
34
|
+
export interface DaveSessionHooks {
|
|
35
|
+
/** Send op 26 with this key package. */
|
|
36
|
+
keyPackage(payload: Uint8Array): void;
|
|
37
|
+
/** Send op 31: this transition could not be applied. */
|
|
38
|
+
invalidTransition(transitionId: number): void;
|
|
39
|
+
debug?(message: string): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One end-to-end encrypted (DAVE) media session: the MLS group of a voice
|
|
43
|
+
* channel, its protocol transitions, and Opus frame encryption. Follows the
|
|
44
|
+
* DAVE protocol's client flow (key package → proposals → commit/welcome →
|
|
45
|
+
* transition ready → execute).
|
|
46
|
+
*/
|
|
47
|
+
export declare class DaveSession {
|
|
48
|
+
#private;
|
|
49
|
+
protocolVersion: number;
|
|
50
|
+
constructor(module: DaveyModule, protocolVersion: number, userId: string, channelId: string, hooks: DaveSessionHooks);
|
|
51
|
+
/** Whether frames are currently end-to-end encrypted. */
|
|
52
|
+
get active(): boolean;
|
|
53
|
+
/** The voice privacy code users can compare, or `null` without DAVE. */
|
|
54
|
+
get voicePrivacyCode(): string | null;
|
|
55
|
+
/** (Re)creates the MLS state and announces a fresh key package. */
|
|
56
|
+
reinit(): void;
|
|
57
|
+
/** Op 25. */
|
|
58
|
+
setExternalSender(payload: Uint8Array): void;
|
|
59
|
+
/** Op 21. @returns Whether to answer with op 23 (transition ready). */
|
|
60
|
+
prepareTransition(transitionId: number, protocolVersion: number): boolean;
|
|
61
|
+
/** Op 22. @returns Whether a pending transition was executed. */
|
|
62
|
+
executeTransition(transitionId: number): boolean;
|
|
63
|
+
/** Op 24. */
|
|
64
|
+
prepareEpoch(epoch: number, protocolVersion: number): void;
|
|
65
|
+
/** Op 27. @returns The op 28 payload (commit, then welcome) to send, if any. */
|
|
66
|
+
processProposals(payload: Uint8Array, connectedUserIds: Iterable<string>): Uint8Array | undefined;
|
|
67
|
+
/** Op 29 (commit) or op 30 (welcome). @returns The transition and whether it applied; a failure re-initializes. */
|
|
68
|
+
process(kind: "commit" | "welcome", payload: Uint8Array): {
|
|
69
|
+
transitionId: number;
|
|
70
|
+
ok: boolean;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* End-to-end encrypts an outgoing Opus frame. Silence frames, frames
|
|
74
|
+
* without DAVE (protocol version 0) and frames during an upgrade from
|
|
75
|
+
* transport-only stay as they are. @returns The frame to send, or `null`
|
|
76
|
+
* to drop it: DAVE is required but the MLS group is not ready (joining, or
|
|
77
|
+
* recovering from an invalid commit), so it must not leave unencrypted.
|
|
78
|
+
*/
|
|
79
|
+
encrypt(frame: Uint8Array): Uint8Array | null;
|
|
80
|
+
/** Decrypts a frame from `userId`. @returns The Opus frame, or `null` to drop it. */
|
|
81
|
+
decrypt(frame: Uint8Array, userId: string): Uint8Array | null;
|
|
82
|
+
/** Drops the MLS state. */
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PCM effect: changes one 20 ms frame of 48 kHz stereo interleaved samples
|
|
3
|
+
* in place. Effects keep state between frames, so use one instance per
|
|
4
|
+
* resource.
|
|
5
|
+
*/
|
|
6
|
+
export interface AudioEffect {
|
|
7
|
+
process(samples: Int16Array): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Shifts the pitch by `semitones` (-24 to 24) without changing the speed:
|
|
11
|
+
* +12 is an octave up (a "chipmunk" voice), -7 a deeper one. A granular
|
|
12
|
+
* delay-line shifter, so it adds about 40 ms of latency.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pitchShift(semitones: number): AudioEffect;
|
|
15
|
+
/** A robot voice: ring modulation with a `frequency` Hz carrier (1 to 2,000, default 50). */
|
|
16
|
+
export declare function robot(frequency?: number): AudioEffect;
|
|
17
|
+
/** Options for {@link echo}. */
|
|
18
|
+
export interface EchoOptions {
|
|
19
|
+
/** Delay in ms (1 to 2,000). Default 250. */
|
|
20
|
+
delay?: number;
|
|
21
|
+
/** How much of each echo is fed back (0 to 0.95). Default 0.4. */
|
|
22
|
+
feedback?: number;
|
|
23
|
+
/** Echo level in the output (0 to 1). Default 0.5. */
|
|
24
|
+
mix?: number;
|
|
25
|
+
}
|
|
26
|
+
/** An echo. Its buffer is fixed by `delay` (at most 2 s, 750 KB). */
|
|
27
|
+
export declare function echo(options?: EchoOptions): AudioEffect;
|
|
28
|
+
/** Linear gain (0 to 16): 0.5 is half, 2 double (clipped). */
|
|
29
|
+
export declare function gain(factor: number): AudioEffect;
|
|
30
|
+
/** @internal Runs `effects` over one s16le PCM frame; returns a new full frame (3,840 bytes). */
|
|
31
|
+
export declare function applyEffects(effects: readonly AudioEffect[], pcm: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A small typed event emitter: listener failures are isolated, nothing is async. */
|
|
2
|
+
export declare class Emitter<E extends {
|
|
3
|
+
[K in keyof E]: unknown[];
|
|
4
|
+
}> {
|
|
5
|
+
#private;
|
|
6
|
+
/** Adds a listener. @throws {TypeError} If it is not a function. */
|
|
7
|
+
on<K extends keyof E>(event: K, listener: (...args: E[K]) => unknown): this;
|
|
8
|
+
/** Removes a listener. */
|
|
9
|
+
off<K extends keyof E>(event: K, listener: (...args: E[K]) => unknown): this;
|
|
10
|
+
/** Calls the listeners of `event`; one that throws does not stop the others. */
|
|
11
|
+
protected emit<K extends keyof E>(event: K, ...args: E[K]): void;
|
|
12
|
+
/** Drops every listener. */
|
|
13
|
+
protected removeAllListeners(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** A JSON voice gateway frame. */
|
|
2
|
+
export interface VoicePacket {
|
|
3
|
+
op: number;
|
|
4
|
+
d?: unknown;
|
|
5
|
+
seq?: number;
|
|
6
|
+
}
|
|
7
|
+
/** A binary voice gateway frame (DAVE): sequence, opcode and payload. */
|
|
8
|
+
export interface VoiceBinaryPacket {
|
|
9
|
+
seq: number;
|
|
10
|
+
op: number;
|
|
11
|
+
payload: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
/** The parts of a WebSocket {@link VoiceGateway} uses; the global `WebSocket` provides them. */
|
|
14
|
+
export interface VoiceSocketLike {
|
|
15
|
+
binaryType: string;
|
|
16
|
+
readonly readyState: number;
|
|
17
|
+
send(data: string | Uint8Array): void;
|
|
18
|
+
close(code?: number, reason?: string): void;
|
|
19
|
+
addEventListener(type: string, listener: (event: never) => void): void;
|
|
20
|
+
}
|
|
21
|
+
/** Opens a WebSocket. Replace it in tests. */
|
|
22
|
+
export type VoiceSocketFactory = (url: string) => VoiceSocketLike;
|
|
23
|
+
/** The default factory: the runtime's global `WebSocket`. */
|
|
24
|
+
export declare const globalVoiceSocket: VoiceSocketFactory;
|
|
25
|
+
/** What a {@link VoiceGateway} reports to its owner. */
|
|
26
|
+
export interface VoiceGatewayHandlers {
|
|
27
|
+
open(): void;
|
|
28
|
+
packet(packet: VoicePacket): void;
|
|
29
|
+
binary(packet: VoiceBinaryPacket): void;
|
|
30
|
+
close(code: number, reason: string): void;
|
|
31
|
+
error(error: Error): void;
|
|
32
|
+
}
|
|
33
|
+
/** Client close code for missed heartbeat ACKs: below 4000, so the session resumes. */
|
|
34
|
+
export declare const HEARTBEAT_TIMEOUT_CLOSE = 3001;
|
|
35
|
+
/** Builds the voice gateway URL for an endpoint from VOICE_SERVER_UPDATE. */
|
|
36
|
+
export declare function voiceGatewayURL(endpoint: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* One voice gateway WebSocket (v8). Parses JSON and binary frames, tracks the
|
|
39
|
+
* last sequence for `seq_ack`, and heartbeats with `@lunibee/ws`'s
|
|
40
|
+
* {@link GatewayHeartbeat} (an unanswered heartbeat closes with
|
|
41
|
+
* {@link HEARTBEAT_TIMEOUT_CLOSE}, which the owner resumes).
|
|
42
|
+
*/
|
|
43
|
+
export declare class VoiceGateway {
|
|
44
|
+
#private;
|
|
45
|
+
/** The last sequence number received, `-1` before any. Sent back as `seq_ack`. */
|
|
46
|
+
sequence: number;
|
|
47
|
+
constructor(url: string, handlers: VoiceGatewayHandlers, options?: {
|
|
48
|
+
factory?: VoiceSocketFactory;
|
|
49
|
+
sequence?: number;
|
|
50
|
+
});
|
|
51
|
+
/** Round trip of the last heartbeat, or -1. */
|
|
52
|
+
get ping(): number;
|
|
53
|
+
/** Sends a JSON frame. @returns Whether the socket was open. */
|
|
54
|
+
sendJSON(packet: VoicePacket): boolean;
|
|
55
|
+
/** Sends a binary frame: the opcode byte followed by the payload. */
|
|
56
|
+
sendBinary(op: number, payload: Uint8Array): boolean;
|
|
57
|
+
/** Closes the socket and stops heartbeating. A `1000` close is not reported back. */
|
|
58
|
+
close(code?: number, reason?: string): void;
|
|
59
|
+
}
|
package/dist/voice/index.d.ts
CHANGED
|
@@ -1,230 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Voice channel to join. */
|
|
18
|
-
channelId?: string;
|
|
19
|
-
/** Whether the self user should be muted. */
|
|
20
|
-
selfMute?: boolean;
|
|
21
|
-
/** Whether the self user should be deafened. */
|
|
22
|
-
selfDeaf?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/** UDP transport supplied by the runtime-specific voice implementation. */
|
|
25
|
-
export interface VoiceUdpTransport {
|
|
26
|
-
/** Sends an RTP/RTCP packet. @param packet Packet bytes. @param host Destination host. @param port Destination port. @returns Optional completion promise. */
|
|
27
|
-
send(packet: Uint8Array, host: string, port: number): Promise<void> | void;
|
|
28
|
-
/** Closes the UDP socket. @returns Nothing. */
|
|
29
|
-
close(): void;
|
|
30
|
-
/** Optional listener for incoming UDP packets. */
|
|
31
|
-
onMessage?(listener: (packet: Uint8Array) => void): void;
|
|
32
|
-
}
|
|
33
|
-
/** A JSON frame for the voice gateway, e.g. `{ op: 5, d: { speaking, delay, ssrc } }`. */
|
|
34
|
-
export interface VoiceGatewayPayload {
|
|
35
|
-
op: number;
|
|
36
|
-
d: Record<string, string | number | boolean | null>;
|
|
37
|
-
}
|
|
38
|
-
/** Voice Gateway transport abstraction. */
|
|
39
|
-
export interface VoiceGatewayTransport {
|
|
40
|
-
/** Opens the voice gateway. @param endpoint Voice gateway endpoint. @param sessionId Voice session identifier. @returns Promise fulfilled when connected. */
|
|
41
|
-
connect(endpoint: string, sessionId: string): Promise<void>;
|
|
42
|
-
/** Sends a voice gateway payload. @param payload Gateway payload. @returns Nothing. */
|
|
43
|
-
send(payload: VoiceGatewayPayload): void;
|
|
44
|
-
/** Closes the voice gateway. @param code Optional close code. @param reason Optional close reason. @returns Nothing. */
|
|
45
|
-
close(code?: number, reason?: string): void;
|
|
46
|
-
}
|
|
47
|
-
/** Speaking flags used by the voice gateway. */
|
|
48
|
-
export declare const SpeakingFlags: {
|
|
49
|
-
readonly Microphone: 1;
|
|
50
|
-
readonly Soundshare: 2;
|
|
51
|
-
readonly Priority: 4;
|
|
52
|
-
};
|
|
53
|
-
/** Voice session event payloads. */
|
|
54
|
-
export interface VoiceEvents {
|
|
55
|
-
/** State transition event. */
|
|
56
|
-
stateChange: [VoiceConnectionState, VoiceConnectionState];
|
|
57
|
-
/** Speaking flag event. */
|
|
58
|
-
speaking: [number, number];
|
|
59
|
-
/** Voice transport error event. */
|
|
60
|
-
error: [VoiceError];
|
|
61
|
-
}
|
|
62
|
-
/** Tracks a Discord voice session and exposes transport-independent lifecycle controls. */
|
|
63
|
-
export declare class VoiceConnection {
|
|
64
|
-
#private;
|
|
65
|
-
/** Current voice connection state. */
|
|
66
|
-
state: VoiceConnectionState;
|
|
67
|
-
/** Guild associated with this voice session. */
|
|
68
|
-
readonly guildId: string;
|
|
69
|
-
/** Voice channel associated with this session. */
|
|
70
|
-
channelId?: string;
|
|
71
|
-
/** Whether the client is self-muted. */
|
|
72
|
-
selfMute: boolean;
|
|
73
|
-
/** Whether the client is self-deafened. */
|
|
74
|
-
selfDeaf: boolean;
|
|
75
|
-
/** Active voice gateway transport, when attached. */
|
|
76
|
-
gateway?: VoiceGatewayTransport;
|
|
77
|
-
/** Active UDP transport, when attached. */
|
|
78
|
-
udp?: VoiceUdpTransport;
|
|
79
|
-
/** Receives incoming audio. */
|
|
80
|
-
readonly receiver: VoiceReceiver;
|
|
81
|
-
/** Creates a voice connection state manager. @param options Guild ID or connection options. @throws {TypeError} If the guild ID is empty. */
|
|
82
|
-
constructor(options: string | VoiceConnectionOptions);
|
|
83
|
-
/** Registers a voice lifecycle listener. @param event Event name. @param listener Listener callback. @returns This connection. @throws {TypeError} If listener is not callable. */
|
|
84
|
-
on<K extends keyof VoiceEvents>(event: K, listener: (...args: VoiceEvents[K]) => unknown): this;
|
|
85
|
-
/** Removes a voice lifecycle listener. @param event Event name. @param listener Listener callback. @returns This connection. */
|
|
86
|
-
off<K extends keyof VoiceEvents>(event: K, listener: (...args: VoiceEvents[K]) => unknown): this;
|
|
87
|
-
/** Attaches protocol transports, replacing and cleaning up the old pair when present. @param gateway Voice gateway transport. @param udp UDP transport. @returns This connection. @throws {VoiceError} If the connection is destroyed. @throws {TypeError} If a transport is missing. */
|
|
88
|
-
attachTransports(gateway: VoiceGatewayTransport, udp: VoiceUdpTransport): this;
|
|
89
|
-
/** Begins the connection lifecycle. @returns Nothing. @throws {VoiceError} If the connection is destroyed. */
|
|
90
|
-
connect(): void;
|
|
91
|
-
/** Disconnects the current voice session. @returns Nothing. */
|
|
92
|
-
disconnect(): void;
|
|
93
|
-
/** Permanently destroys this voice connection. @returns Nothing. */
|
|
94
|
-
destroy(): void;
|
|
95
|
-
/** Updates the voice channel and connection state. @param channelId Voice channel identifier. @returns Nothing. @throws {VoiceError} If the connection is destroyed. @throws {TypeError} If channelId is empty. */
|
|
96
|
-
setChannel(channelId: string): void;
|
|
97
|
-
/** Updates self mute/deaf state. @param options Suppression flags. @returns Nothing. @throws {VoiceError} If the connection is destroyed. */
|
|
98
|
-
setSuppression(options: {
|
|
99
|
-
selfMute?: boolean;
|
|
100
|
-
selfDeaf?: boolean;
|
|
101
|
-
}): void;
|
|
102
|
-
/** Publishes a speaking state through the attached voice gateway. @param flags Speaking flags. @returns Nothing. @throws {VoiceError} If the connection is destroyed or has no gateway transport. */
|
|
103
|
-
/**
|
|
104
|
-
* Sends a speaking update (voice op 5). Pass the `ssrc` your voice gateway
|
|
105
|
-
* assigned in READY; Discord uses it to match the audio to this user.
|
|
106
|
-
*/
|
|
107
|
-
setSpeaking(flags?: number, ssrc?: number): void;
|
|
108
|
-
/** Ensures the connection is still usable. @returns Nothing. @throws {VoiceError} If destroyed. */
|
|
109
|
-
private assertUsable;
|
|
110
|
-
}
|
|
111
|
-
/** Audio player lifecycle states. */
|
|
112
|
-
export type AudioPlayerState = "idle" | "playing" | "paused" | "stopped";
|
|
113
|
-
/** An audio stream — wraps a `ReadableStream<Uint8Array>` with optional metadata. */
|
|
114
|
-
export declare class AudioStream {
|
|
115
|
-
/** Underlying binary stream. */
|
|
116
|
-
readonly stream: ReadableStream<Uint8Array>;
|
|
117
|
-
/** Optional human-readable title for the stream. */
|
|
118
|
-
readonly title?: string;
|
|
119
|
-
/** Optional duration hint in seconds. */
|
|
120
|
-
readonly duration?: number;
|
|
121
|
-
/** Creates an audio stream.
|
|
122
|
-
* @param stream Binary audio data stream.
|
|
123
|
-
* @param metadata Optional metadata: title and duration in seconds.
|
|
124
|
-
*/
|
|
125
|
-
constructor(stream: ReadableStream<Uint8Array>, metadata?: {
|
|
126
|
-
title?: string;
|
|
127
|
-
duration?: number;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
type AudioPlayerListener<K extends keyof AudioPlayerEvents> = (...args: AudioPlayerEvents[K]) => unknown;
|
|
131
|
-
interface AudioPlayerEvents {
|
|
132
|
-
stateChange: [from: AudioPlayerState, to: AudioPlayerState];
|
|
133
|
-
error: [error: Error];
|
|
134
|
-
finish: [];
|
|
135
|
-
}
|
|
1
|
+
import { VoiceConnection, type VoiceConnectionStatus } from "./connection.js";
|
|
2
|
+
import { AudioPlayer, type AudioPlayerStatus } from "./player.js";
|
|
3
|
+
export { VOICE_GATEWAY_VERSION, VoiceOpcodes, VoiceCloseCodes, canResumeVoice, RTP_OPUS_PAYLOAD_TYPE, FRAME_DURATION_MS, FRAME_SAMPLES, PCM_FRAME_BYTES, SILENCE_FRAME, SpeakingFlags, VoiceError, } from "./protocol.js";
|
|
4
|
+
export { PacketCipher, SUPPORTED_ENCRYPTION_MODES, chooseEncryptionMode, parseRtpHeader, rtpHeader, type RtpHeader, type VoiceEncryptionMode, } from "./crypto.js";
|
|
5
|
+
export { VoiceGateway, voiceGatewayURL, HEARTBEAT_TIMEOUT_CLOSE, type VoiceBinaryPacket, type VoiceGatewayHandlers, type VoicePacket, type VoiceSocketFactory, type VoiceSocketLike, } from "./gateway.js";
|
|
6
|
+
export { VoiceUdp, bunUdpSocket, discoveryRequest, parseDiscoveryResponse, type UdpSocketFactory, type UdpSocketLike, } from "./udp.js";
|
|
7
|
+
export { DaveSession, loadDave, maxDaveProtocolVersion, type DaveSessionHooks, } from "./dave.js";
|
|
8
|
+
export { VoiceNetworking, type NetworkingState, type VoiceNetworkingHandlers, type VoiceNetworkingOptions, type VoiceServerInfo, } from "./networking.js";
|
|
9
|
+
export { createOpusCodec, type OpusCodec } from "./opus.js";
|
|
10
|
+
export { Opus, OpusApplication, hasLibopus, libopusVersion, loadLibopus, } from "./libopus.js";
|
|
11
|
+
export { demuxOggOpus, OggOpusWriter } from "./ogg.js";
|
|
12
|
+
export { pitchShift, robot, echo, gain, type AudioEffect, type EchoOptions, } from "./effects.js";
|
|
13
|
+
export { AudioResource, VolumeControl, createAudioResource, type AudioInput, type AudioResourceOptions, type StreamType, } from "./resource.js";
|
|
14
|
+
export { AudioPlayer, AudioPlayerStatus, createAudioPlayer, type AudioPlayerEvents, type AudioPlayerOptions, type AudioSink, } from "./player.js";
|
|
15
|
+
export { VoiceReceiver, type ReceiveEnd, type ReceiveOptions, type RecordOptions, } from "./receiver.js";
|
|
16
|
+
export { VoiceConnection, VoiceConnectionStatus, VoiceManager, getVoiceConnection, joinVoiceChannel, type DisconnectReason, type JoinVoiceChannelOptions, type PlayerSubscription, type VoiceAdapter, type VoiceAdapterCreator, type VoiceAdapterMethods, type VoiceConnectionEvents, type VoiceJoinOptions, type VoiceManagerClient, type VoiceServerData, type VoiceStateData, type VoiceStatePayload, } from "./connection.js";
|
|
136
17
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* States:
|
|
140
|
-
* - `idle` — no stream loaded.
|
|
141
|
-
* - `playing` — actively feeding audio data.
|
|
142
|
-
* - `paused` — temporarily suspended; can be resumed.
|
|
143
|
-
* - `stopped` — stream was stopped and discarded; load a new stream to play again.
|
|
144
|
-
*
|
|
145
|
-
* Events: `stateChange(from, to)`, `error(err)`, `finish()`.
|
|
18
|
+
* Resolves once `target` reaches `status`, or rejects after `timeoutMs`.
|
|
19
|
+
* @throws {VoiceError} If the status is not reached in time.
|
|
146
20
|
*/
|
|
147
|
-
export declare
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* Begins playing an audio stream.
|
|
155
|
-
* If a stream is already playing, it is stopped first; the previous
|
|
156
|
-
* stream's reader cancellation is awaited before the new stream starts so
|
|
157
|
-
* the old and new pump loops cannot run concurrently.
|
|
158
|
-
* @param audioStream Stream to play.
|
|
159
|
-
*/
|
|
160
|
-
play(audioStream: AudioStream): Promise<void>;
|
|
161
|
-
/** Pauses a currently-playing stream. No-op if not playing. */
|
|
162
|
-
pause(): void;
|
|
163
|
-
/** Resumes a paused stream. No-op if not paused. */
|
|
164
|
-
resume(): void;
|
|
165
|
-
/**
|
|
166
|
-
* Stops and discards the current stream. The returned promise resolves once
|
|
167
|
-
* the underlying reader's cancellation has settled, so a subsequent `play`
|
|
168
|
-
* never overlaps with the previous pump loop.
|
|
169
|
-
*/
|
|
170
|
-
stop(): Promise<void>;
|
|
171
|
-
/** Registers an event listener. @returns `this` for chaining. */
|
|
172
|
-
on<K extends keyof AudioPlayerEvents>(event: K, listener: AudioPlayerListener<K>): this;
|
|
173
|
-
/** Removes an event listener. @returns `this` for chaining. */
|
|
174
|
-
off<K extends keyof AudioPlayerEvents>(event: K, listener: AudioPlayerListener<K>): this;
|
|
175
|
-
/**
|
|
176
|
-
* Handles a decoded audio chunk. The base implementation is a no-op;
|
|
177
|
-
* subclasses override this to pipe audio to a UDP socket or other sink.
|
|
178
|
-
* @param chunk A chunk of audio bytes read from the current stream.
|
|
179
|
-
*/
|
|
180
|
-
protected onChunk(chunk: Uint8Array): void;
|
|
181
|
-
}
|
|
182
|
-
/** Tracks incoming audio and maps SSRCs to readable streams per user. */
|
|
183
|
-
export declare class VoiceReceiver {
|
|
184
|
-
#private;
|
|
185
|
-
/** The connection this receiver is attached to. */
|
|
186
|
-
readonly connection: VoiceConnection;
|
|
187
|
-
/** Creates a VoiceReceiver. @param connection Voice connection. */
|
|
188
|
-
constructor(connection: VoiceConnection);
|
|
189
|
-
/** Maps an SSRC to a User ID (usually from gateway speaking events). */
|
|
190
|
-
mapSsrc(ssrc: number, userId: string): void;
|
|
191
|
-
/** Subscribes to incoming audio from a specific user. @param userId User identifier. @returns A binary readable stream of the audio. */
|
|
192
|
-
subscribe(userId: string): AudioStream;
|
|
193
|
-
/** Ends every subscriber stream and forgets SSRC mappings. Called when the
|
|
194
|
-
* connection disconnects or is destroyed, so readers do not wait forever. */
|
|
195
|
-
close(): void;
|
|
196
|
-
/** Processes an incoming UDP packet, extracting SSRC and routing the audio
|
|
197
|
-
* payload (RTP header stripped) to every subscriber for the mapped user. */
|
|
198
|
-
onPacket(packet: Uint8Array): void;
|
|
199
|
-
}
|
|
200
|
-
/** Discord.js-familiar alias for {@link VoiceConnectionState}. Member values are Lunibee's. */
|
|
201
|
-
export { VoiceConnectionState as VoiceConnectionStatus };
|
|
202
|
-
/**
|
|
203
|
-
* Joins (or moves to) a voice channel, reusing the guild's tracked connection.
|
|
204
|
-
* Mirrors `@discordjs/voice`'s `joinVoiceChannel`; transports are still attached
|
|
205
|
-
* with {@link VoiceConnection.attachTransports}.
|
|
206
|
-
* The connection stays tracked after `disconnect()` (a later join reuses it) and
|
|
207
|
-
* leaves the registry only on `destroy()`.
|
|
208
|
-
* @param options Guild, channel and self mute/deaf flags.
|
|
209
|
-
* @returns The guild's voice connection.
|
|
210
|
-
* @throws {TypeError} If the guild or channel ID is empty.
|
|
211
|
-
*/
|
|
212
|
-
export declare function joinVoiceChannel(options: VoiceConnectionOptions & {
|
|
213
|
-
channelId: string;
|
|
214
|
-
}): VoiceConnection;
|
|
215
|
-
/** Returns the connection tracked by {@link joinVoiceChannel} for a guild, if any. */
|
|
216
|
-
export declare function getVoiceConnection(guildId: string): VoiceConnection | undefined;
|
|
217
|
-
/** Creates an {@link AudioPlayer}. Mirrors `@discordjs/voice`'s `createAudioPlayer`. */
|
|
218
|
-
export declare function createAudioPlayer(): AudioPlayer;
|
|
219
|
-
/** Creates an {@link AudioStream}. Mirrors `@discordjs/voice`'s `createAudioResource`. */
|
|
220
|
-
export declare function createAudioResource(stream: ReadableStream<Uint8Array>, metadata?: {
|
|
221
|
-
title?: string;
|
|
222
|
-
duration?: number;
|
|
223
|
-
}): AudioStream;
|
|
224
|
-
/**
|
|
225
|
-
* Resolves once a connection or player reaches `status`, or rejects after `timeoutMs`.
|
|
226
|
-
* Mirrors `@discordjs/voice`'s `entersState`.
|
|
227
|
-
* @returns The same target, for chaining.
|
|
228
|
-
* @throws {VoiceError} If the state is not reached in time.
|
|
229
|
-
*/
|
|
230
|
-
export declare function entersState<T extends VoiceConnection | AudioPlayer>(target: T, status: T extends VoiceConnection ? VoiceConnectionState : AudioPlayerState, timeoutMs: number): Promise<T>;
|
|
21
|
+
export declare function entersState<T extends VoiceConnection | AudioPlayer>(target: T, status: T extends VoiceConnection ? VoiceConnectionStatus : AudioPlayerStatus, timeoutMs: number): Promise<T>;
|
|
22
|
+
/** Which optional voice dependencies this runtime can load. */
|
|
23
|
+
export declare function generateDependencyReport(): Promise<{
|
|
24
|
+
dave: string | null;
|
|
25
|
+
opus: string | null;
|
|
26
|
+
ffmpeg: string | null;
|
|
27
|
+
}>;
|