@discordjs/voice
Advanced tools
Comparing version 0.7.5 to 0.8.0
@@ -555,3 +555,3 @@ import { Readable, ReadableOptions } from 'node:stream'; | ||
*/ | ||
onVoiceServerUpdate(data: GatewayVoiceServerUpdateDispatchData): void; | ||
onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void; | ||
/** | ||
@@ -562,7 +562,7 @@ * Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter. | ||
*/ | ||
onVoiceStateUpdate(data: GatewayVoiceStateUpdateDispatchData): void; | ||
onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void; | ||
/** | ||
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway) | ||
*/ | ||
destroy(): void; | ||
destroy: () => void; | ||
} | ||
@@ -580,3 +580,3 @@ /** | ||
*/ | ||
sendPayload(payload: any): boolean; | ||
sendPayload: (payload: any) => boolean; | ||
/** | ||
@@ -586,3 +586,3 @@ * This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no | ||
*/ | ||
destroy(): void; | ||
destroy: () => void; | ||
} | ||
@@ -589,0 +589,0 @@ /** |
@@ -1,10 +0,10 @@ | ||
var ze=Object.create;var M=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var et=(i,e,t)=>e in i?M(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var re=i=>M(i,"__esModule",{value:!0});var tt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),it=(i,e)=>{re(i);for(var t in e)M(i,t,{get:e[t],enumerable:!0})},st=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xe(e))!Qe.call(i,s)&&s!=="default"&&M(i,s,{get:()=>e[s],enumerable:!(t=Ye(e,s))||t.enumerable});return i},h=i=>st(re(M(i!=null?ze(Ze(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var r=(i,e,t)=>(et(i,typeof e!="symbol"?e+"":e,t),t);var Fe=tt((Li,Pt)=>{Pt.exports={name:"@discordjs/voice",version:"0.7.4",description:"Implementation of the Discord Voice API for Node.js",scripts:{pretest:"npm run build",test:"jest --pass-with-no-tests","test:ci":"jest --no-stack-trace --verbose --pass-with-no-tests",prebuild:"npm run lint",build:"tsup",postbuild:"node scripts/postbuild.mjs",lint:"eslint src --ext mjs,js,ts","lint:fix":"eslint src --ext mjs,js,ts --fix",format:"prettier --write **/*.{ts,js,json,yml,yaml}",prepare:"is-ci || husky install",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"npm run lint && npm run test",release:"standard-version --preset angular"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js"},directories:{lib:"src",test:"__tests__"},files:["dist"],author:"Amish Shah <amish@shah.gg>",license:"Apache-2.0",keywords:["discord","discord.js","audio","voice","streaming"],repository:{type:"git",url:"git+https://github.com/discordjs/voice.git"},bugs:{url:"https://github.com/discordjs/voice/issues"},homepage:"https://github.com/discordjs/voice",dependencies:{"@types/ws":"^8.2.0","discord-api-types":"^0.24.0","prism-media":"^1.3.2","tiny-typed-emitter":"^2.1.0",tslib:"^2.3.1",ws:"^8.2.3"},devDependencies:{"@babel/core":"^7.16.0","@babel/preset-env":"^7.16.0","@babel/preset-typescript":"^7.16.0","@commitlint/cli":"^14.1.0","@commitlint/config-angular":"^14.1.0","@discordjs/ts-docgen":"^0.3.2","@types/jest":"^27.0.2","@types/node":"^16.11.7","@typescript-eslint/eslint-plugin":"^5.3.1","@typescript-eslint/parser":"^5.3.1",eslint:"^8.2.0","eslint-config-marine":"^9.0.6","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",husky:"^7.0.4","is-ci":"^3.0.1",jest:"^27.3.1","jest-websocket-mock":"^2.2.1","lint-staged":"^11.2.6","mock-socket":"^9.0.7",prettier:"^2.4.1","standard-version":"^9.3.2",tsup:"^5.7.0",typedoc:"^0.22.8",typescript:"^4.4.4"},engines:{node:">=16.0.0",npm:">=7.0.0"},publishConfig:{access:"public"}}});it(exports,{AudioPlayer:()=>H,AudioPlayerError:()=>N,AudioPlayerStatus:()=>d,AudioReceiveStream:()=>J,AudioResource:()=>j,EndBehaviorType:()=>I,NoSubscriberBehavior:()=>x,PlayerSubscription:()=>W,SSRCMap:()=>L,SpeakingMap:()=>T,StreamType:()=>p,VoiceConnection:()=>K,VoiceConnectionDisconnectReason:()=>y,VoiceConnectionStatus:()=>c,VoiceReceiver:()=>q,createAudioPlayer:()=>De,createAudioResource:()=>je,createDefaultAudioReceiveStreamOptions:()=>ie,demuxProbe:()=>xt,entersState:()=>wt,generateDependencyReport:()=>Ct,getGroups:()=>ce,getVoiceConnection:()=>B,getVoiceConnections:()=>G,joinVoiceChannel:()=>gt,validateDiscordOpusHead:()=>qe});var ae=h(require("discord-api-types/v9"));function R(i){return{op:ae.GatewayOpcodes.VoiceStateUpdate,d:{guild_id:i.guildId,channel_id:i.channelId,self_deaf:i.selfDeaf,self_mute:i.selfMute}}}var U=new Map;U.set("default",new Map);function ot(i){let e=U.get(i);if(e)return e;let t=new Map;return U.set(i,t),t}function ce(){return U}function G(i="default"){return U.get(i)}function B(i,e="default"){return G(e)?.get(i)}function de(i){return G(i.joinConfig.group)?.delete(i.joinConfig.guildId)}function ue(i){return ot(i.joinConfig.group).set(i.joinConfig.guildId,i)}var nt=20,Y,V=-1,w=[];function pe(){if(V===-1)return;V+=nt;let i=w.filter(e=>e.checkPlayable());i.forEach(e=>e._stepDispatch()),le(i)}function le(i){let e=i.shift();if(!e){V!==-1&&(Y=setTimeout(()=>pe(),V-Date.now()));return}e._stepPrepare(),setImmediate(()=>le(i))}function rt(i){return w.includes(i)}function fe(i){return rt(i)||(w.push(i),w.length===1&&(V=Date.now(),setImmediate(()=>pe()))),i}function he(i){let e=w.indexOf(i);e!==-1&&(w.splice(e,1),w.length===0&&(V=-1,typeof Y!="undefined"&&clearTimeout(Y)))}var k=h(require("discord-api-types/voice/v4"));var me=h(require("node:dgram")),ge=h(require("node:net")),ye=h(require("tiny-typed-emitter")),at=5e3,ct=12,dt=2**32-1,X=class extends ye.TypedEmitter{constructor(e,t=!1){super();r(this,"socket");r(this,"remote");r(this,"keepAlives");r(this,"keepAliveCounter",0);r(this,"keepAliveBuffer");r(this,"keepAliveInterval");r(this,"ping");r(this,"debug");this.socket=(0,me.createSocket)("udp4"),this.socket.on("error",s=>this.emit("error",s)),this.socket.on("message",s=>this.onMessage(s)),this.socket.on("close",()=>this.emit("close")),this.remote=e,this.keepAlives=[],this.keepAliveBuffer=Buffer.alloc(8),this.keepAliveInterval=setInterval(()=>this.keepAlive(),at),setImmediate(()=>this.keepAlive()),this.debug=t?s=>this.emit("debug",s):null}onMessage(e){if(e.length===8){let t=e.readUInt32LE(0),s=this.keepAlives.findIndex(({value:n})=>n===t);if(s===-1)return;this.ping=Date.now()-this.keepAlives[s].timestamp,this.keepAlives.splice(0,s)}this.emit("message",e)}keepAlive(){if(this.keepAlives.length>=ct){this.debug?.("UDP socket has not received enough responses from Discord - closing socket"),this.destroy();return}this.keepAliveBuffer.writeUInt32LE(this.keepAliveCounter,0),this.send(this.keepAliveBuffer),this.keepAlives.push({value:this.keepAliveCounter,timestamp:Date.now()}),this.keepAliveCounter++,this.keepAliveCounter>dt&&(this.keepAliveCounter=0)}send(e){return this.socket.send(e,this.remote.port,this.remote.ip)}destroy(){try{this.socket.close()}catch{}clearInterval(this.keepAliveInterval)}performIPDiscovery(e){return new Promise((t,s)=>{let n=u=>{try{if(u.readUInt16BE(0)!==2)return;let a=ut(u);this.socket.off("message",n),t(a)}catch{}};this.socket.on("message",n),this.socket.once("close",()=>s(new Error("Cannot perform IP discovery - socket closed")));let o=Buffer.alloc(74);o.writeUInt16BE(1,0),o.writeUInt16BE(70,2),o.writeUInt32BE(e,4),this.send(o)})}};function ut(i){let e=Buffer.from(i),t=e.slice(8,e.indexOf(0,8)).toString("utf-8");if(!(0,ge.isIPv4)(t))throw new Error("Malformed IP address");let s=e.readUInt16BE(e.length-2);return{ip:t,port:s}}var Z=h(require("discord-api-types/voice/v4")),be=h(require("ws")),Se=h(require("tiny-typed-emitter")),Q=class extends Se.TypedEmitter{constructor(e,t){super();r(this,"heartbeatInterval");r(this,"lastHeartbeatAck");r(this,"lastHeatbeatSend");r(this,"missedHeartbeats",0);r(this,"ping");r(this,"debug");r(this,"ws");this.ws=new be.default(e),this.ws.onmessage=s=>this.onMessage(s),this.ws.onopen=s=>this.emit("open",s),this.ws.onerror=s=>this.emit("error",s instanceof Error?s:s.error),this.ws.onclose=s=>this.emit("close",s),this.lastHeartbeatAck=0,this.lastHeatbeatSend=0,this.debug=t?s=>this.emit("debug",s):null}destroy(){try{this.debug?.("destroyed"),this.setHeartbeatInterval(-1),this.ws.close(1e3)}catch(e){let t=e;this.emit("error",t)}}onMessage(e){if(typeof e.data!="string")return;this.debug?.(`<< ${e.data}`);let t;try{t=JSON.parse(e.data)}catch(s){let n=s;this.emit("error",n);return}t.op===Z.VoiceOpcodes.HeartbeatAck&&(this.lastHeartbeatAck=Date.now(),this.missedHeartbeats=0,this.ping=this.lastHeartbeatAck-this.lastHeatbeatSend),this.emit("packet",t)}sendPacket(e){try{let t=JSON.stringify(e);return this.debug?.(`>> ${t}`),this.ws.send(t)}catch(t){let s=t;this.emit("error",s)}}sendHeartbeat(){this.lastHeatbeatSend=Date.now(),this.missedHeartbeats++;let e=this.lastHeatbeatSend;return this.sendPacket({op:Z.VoiceOpcodes.Heartbeat,d:e})}setHeartbeatInterval(e){typeof this.heartbeatInterval!="undefined"&&clearInterval(this.heartbeatInterval),e>0&&(this.heartbeatInterval=setInterval(()=>{this.lastHeatbeatSend!==0&&this.missedHeartbeats>=3&&(this.ws.close(),this.setHeartbeatInterval(-1)),this.sendHeartbeat()},e))}};var ke={sodium:i=>({open:i.api.crypto_secretbox_open_easy,close:i.api.crypto_secretbox_easy,random:(e,t)=>(t||(t=Buffer.allocUnsafe(e)),i.api.randombytes_buf(t),t)}),"libsodium-wrappers":i=>({open:i.crypto_secretbox_open_easy,close:i.crypto_secretbox_easy,random:e=>i.randombytes_buf(e)}),tweetnacl:i=>({open:i.secretbox.open,close:i.secretbox,random:e=>i.randomBytes(e)})},ee=()=>{throw new Error(`Cannot play audio as no valid encryption package is installed. | ||
var Ke=Object.create;var x=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var Qe=(i,e,t)=>e in i?x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var oe=i=>x(i,"__esModule",{value:!0});var et=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),tt=(i,e)=>{for(var t in e)x(i,t,{get:e[t],enumerable:!0})},se=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ye(e))!Ze.call(i,s)&&(t||s!=="default")&&x(i,s,{get:()=>e[s],enumerable:!(o=ze(e,s))||o.enumerable});return i},V=(i,e)=>se(oe(x(i!=null?Ke(Xe(i)):{},"default",!e&&i&&i.__esModule?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i),it=(i=>(e,t)=>i&&i.get(e)||(t=se(oe({}),e,1),i&&i.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var r=(i,e,t)=>(Qe(i,typeof e!="symbol"?e+"":e,t),t);var Fe=et(($i,At)=>{At.exports={name:"@discordjs/voice",version:"0.8.0",description:"Implementation of the Discord Voice API for node.js",scripts:{build:"tsup && node scripts/postbuild.mjs",test:"jest --pass-with-no-tests --collect-coverage",lint:"prettier --check . && eslint src __tests__ --ext mjs,js,ts",format:"prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"yarn build && yarn lint && yarn test",changelog:"git cliff --prepend ./CHANGELOG.md -l -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js"},directories:{lib:"src",test:"__tests__"},files:["dist"],contributors:["Crawl <icrawltogo@gmail.com>","Amish Shah <amishshah.2k@gmail.com>","SpaceEEC <spaceeec@yahoo.com>","Vlad Frangu <kingdgrizzle@gmail.com>","Antonio Roman <kyradiscord@gmail.com>"],license:"Apache-2.0",keywords:["discord","discord.js","audio","voice","streaming"],repository:{type:"git",url:"git+https://github.com/discordjs/discord.js.git"},bugs:{url:"https://github.com/discordjs/discord.js/issues"},homepage:"https://discord.js.org",dependencies:{"@types/ws":"^8.2.0","discord-api-types":"^0.26.1","prism-media":"^1.3.2","tiny-typed-emitter":"^2.1.0",tslib:"^2.3.1",ws:"^8.4.2"},devDependencies:{"@babel/core":"^7.16.12","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.0","@discordjs/ts-docgen":"^0.3.2","@types/jest":"^27.0.2","@types/node":"^16.11.7","@typescript-eslint/eslint-plugin":"^5.10.0","@typescript-eslint/parser":"^5.10.0",eslint:"^8.7.0","eslint-config-marine":"^9.3.2","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",jest:"^27.4.7","jest-websocket-mock":"^2.3.0","mock-socket":"^9.1.0",prettier:"^2.4.1","standard-version":"^9.3.2",tsup:"^5.11.11",tweetnacl:"^1.0.3",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});var Vt={};tt(Vt,{AudioPlayer:()=>B,AudioPlayerError:()=>R,AudioPlayerStatus:()=>X,AudioReceiveStream:()=>U,AudioResource:()=>T,EndBehaviorType:()=>Ve,NoSubscriberBehavior:()=>Y,PlayerSubscription:()=>O,SSRCMap:()=>W,SpeakingMap:()=>I,StreamType:()=>v,VoiceConnection:()=>G,VoiceConnectionDisconnectReason:()=>ee,VoiceConnectionStatus:()=>M,VoiceReceiver:()=>j,createAudioPlayer:()=>we,createAudioResource:()=>We,createDefaultAudioReceiveStreamOptions:()=>Z,demuxProbe:()=>xt,entersState:()=>wt,generateDependencyReport:()=>vt,getGroups:()=>re,getVoiceConnection:()=>E,getVoiceConnections:()=>N,joinVoiceChannel:()=>gt,validateDiscordOpusHead:()=>$e});var ne=require("discord-api-types/v9");function k(i){return{op:ne.GatewayOpcodes.VoiceStateUpdate,d:{guild_id:i.guildId,channel_id:i.channelId,self_deaf:i.selfDeaf,self_mute:i.selfMute}}}var D=new Map;D.set("default",new Map);function ot(i){let e=D.get(i);if(e)return e;let t=new Map;return D.set(i,t),t}function re(){return D}function N(i="default"){return D.get(i)}function E(i,e="default"){return N(e)?.get(i)}function ae(i){return N(i.joinConfig.group)?.delete(i.joinConfig.guildId)}function ce(i){return ot(i.joinConfig.group).set(i.joinConfig.guildId,i)}var st=20,J,A=-1,b=[];function de(){if(A===-1)return;A+=st;let i=b.filter(e=>e.checkPlayable());i.forEach(e=>e._stepDispatch()),ue(i)}function ue(i){let e=i.shift();if(!e){A!==-1&&(J=setTimeout(()=>de(),A-Date.now()));return}e._stepPrepare(),setImmediate(()=>ue(i))}function nt(i){return b.includes(i)}function pe(i){return nt(i)||(b.push(i),b.length===1&&(A=Date.now(),setImmediate(()=>de()))),i}function le(i){let e=b.indexOf(i);e!==-1&&(b.splice(e,1),b.length===0&&(A=-1,typeof J!="undefined"&&clearTimeout(J)))}var f=require("discord-api-types/voice/v4");var fe=require("dgram"),he=require("net"),me=require("tiny-typed-emitter");function rt(i){let e=Buffer.from(i),t=e.slice(8,e.indexOf(0,8)).toString("utf-8");if(!(0,he.isIPv4)(t))throw new Error("Malformed IP address");let o=e.readUInt16BE(e.length-2);return{ip:t,port:o}}var at=5e3,ct=12,dt=2**32-1,L=class extends me.TypedEmitter{constructor(e,t=!1){super();r(this,"socket");r(this,"remote");r(this,"keepAlives");r(this,"keepAliveCounter",0);r(this,"keepAliveBuffer");r(this,"keepAliveInterval");r(this,"ping");r(this,"debug");this.socket=(0,fe.createSocket)("udp4"),this.socket.on("error",o=>this.emit("error",o)),this.socket.on("message",o=>this.onMessage(o)),this.socket.on("close",()=>this.emit("close")),this.remote=e,this.keepAlives=[],this.keepAliveBuffer=Buffer.alloc(8),this.keepAliveInterval=setInterval(()=>this.keepAlive(),at),setImmediate(()=>this.keepAlive()),this.debug=t?o=>this.emit("debug",o):null}onMessage(e){if(e.length===8){let t=e.readUInt32LE(0),o=this.keepAlives.findIndex(({value:s})=>s===t);if(o===-1)return;this.ping=Date.now()-this.keepAlives[o].timestamp,this.keepAlives.splice(0,o)}this.emit("message",e)}keepAlive(){if(this.keepAlives.length>=ct){this.debug?.("UDP socket has not received enough responses from Discord - closing socket"),this.destroy();return}this.keepAliveBuffer.writeUInt32LE(this.keepAliveCounter,0),this.send(this.keepAliveBuffer),this.keepAlives.push({value:this.keepAliveCounter,timestamp:Date.now()}),this.keepAliveCounter++,this.keepAliveCounter>dt&&(this.keepAliveCounter=0)}send(e){return this.socket.send(e,this.remote.port,this.remote.ip)}destroy(){try{this.socket.close()}catch{}clearInterval(this.keepAliveInterval)}performIPDiscovery(e){return new Promise((t,o)=>{let s=a=>{try{if(a.readUInt16BE(0)!==2)return;let d=rt(a);this.socket.off("message",s),t(d)}catch{}};this.socket.on("message",s),this.socket.once("close",()=>o(new Error("Cannot perform IP discovery - socket closed")));let n=Buffer.alloc(74);n.writeUInt16BE(1,0),n.writeUInt16BE(70,2),n.writeUInt32BE(e,4),this.send(n)})}};var $=require("discord-api-types/voice/v4"),ge=V(require("ws")),ye=require("tiny-typed-emitter"),q=class extends ye.TypedEmitter{constructor(e,t){super();r(this,"heartbeatInterval");r(this,"lastHeartbeatAck");r(this,"lastHeatbeatSend");r(this,"missedHeartbeats",0);r(this,"ping");r(this,"debug");r(this,"ws");this.ws=new ge.default(e),this.ws.onmessage=o=>this.onMessage(o),this.ws.onopen=o=>this.emit("open",o),this.ws.onerror=o=>this.emit("error",o instanceof Error?o:o.error),this.ws.onclose=o=>this.emit("close",o),this.lastHeartbeatAck=0,this.lastHeatbeatSend=0,this.debug=t?o=>this.emit("debug",o):null}destroy(){try{this.debug?.("destroyed"),this.setHeartbeatInterval(-1),this.ws.close(1e3)}catch(e){let t=e;this.emit("error",t)}}onMessage(e){if(typeof e.data!="string")return;this.debug?.(`<< ${e.data}`);let t;try{t=JSON.parse(e.data)}catch(o){let s=o;this.emit("error",s);return}t.op===$.VoiceOpcodes.HeartbeatAck&&(this.lastHeartbeatAck=Date.now(),this.missedHeartbeats=0,this.ping=this.lastHeartbeatAck-this.lastHeatbeatSend),this.emit("packet",t)}sendPacket(e){try{let t=JSON.stringify(e);return this.debug?.(`>> ${t}`),this.ws.send(t)}catch(t){let o=t;this.emit("error",o)}}sendHeartbeat(){this.lastHeatbeatSend=Date.now(),this.missedHeartbeats++;let e=this.lastHeatbeatSend;return this.sendPacket({op:$.VoiceOpcodes.Heartbeat,d:e})}setHeartbeatInterval(e){typeof this.heartbeatInterval!="undefined"&&clearInterval(this.heartbeatInterval),e>0&&(this.heartbeatInterval=setInterval(()=>{this.lastHeatbeatSend!==0&&this.missedHeartbeats>=3&&(this.ws.close(),this.setHeartbeatInterval(-1)),this.sendHeartbeat()},e))}};var be={sodium:i=>({open:i.api.crypto_secretbox_open_easy,close:i.api.crypto_secretbox_easy,random:(e,t)=>(t||(t=Buffer.allocUnsafe(e)),i.api.randombytes_buf(t),t)}),"libsodium-wrappers":i=>({open:i.crypto_secretbox_open_easy,close:i.crypto_secretbox_easy,random:e=>i.randombytes_buf(e)}),tweetnacl:i=>({open:i.secretbox.open,close:i.secretbox,random:e=>i.randomBytes(e)})},K=()=>{throw new Error(`Cannot play audio as no valid encryption package is installed. | ||
- Install sodium, libsodium-wrappers, or tweetnacl. | ||
- Use the generateDependencyReport() function for more information. | ||
`)},C={open:ee,close:ee,random:ee};(async()=>{for(let i of Object.keys(ke))try{let e=require(i);i==="libsodium-wrappers"&&e.ready&&await e.ready,Object.assign(C,ke[i](e));break}catch{}})();var g=()=>{};var ve=h(require("tiny-typed-emitter")),pt=2,lt=48e3/100*pt,ft=2**32-1,ht=["xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"],l;(function(a){a[a.OpeningWs=0]="OpeningWs",a[a.Identifying=1]="Identifying",a[a.UdpHandshaking=2]="UdpHandshaking",a[a.SelectingProtocol=3]="SelectingProtocol",a[a.Ready=4]="Ready",a[a.Resuming=5]="Resuming",a[a.Closed=6]="Closed"})(l||(l={}));var Pe=Buffer.alloc(24),te=class extends ve.TypedEmitter{constructor(e,t){super();r(this,"_state");r(this,"debug");this.onWsOpen=this.onWsOpen.bind(this),this.onChildError=this.onChildError.bind(this),this.onWsPacket=this.onWsPacket.bind(this),this.onWsClose=this.onWsClose.bind(this),this.onWsDebug=this.onWsDebug.bind(this),this.onUdpDebug=this.onUdpDebug.bind(this),this.onUdpClose=this.onUdpClose.bind(this),this.debug=t?s=>this.emit("debug",s):null,this._state={code:0,ws:this.createWebSocket(e.endpoint),connectionOptions:e}}destroy(){this.state={code:6}}get state(){return this._state}set state(e){let t=Reflect.get(this._state,"ws"),s=Reflect.get(e,"ws");t&&t!==s&&(t.off("debug",this.onWsDebug),t.on("error",g),t.off("error",this.onChildError),t.off("open",this.onWsOpen),t.off("packet",this.onWsPacket),t.off("close",this.onWsClose),t.destroy());let n=Reflect.get(this._state,"udp"),o=Reflect.get(e,"udp");n&&n!==o&&(n.on("error",g),n.off("error",this.onChildError),n.off("close",this.onUdpClose),n.off("debug",this.onUdpDebug),n.destroy());let u=this._state;this._state=e,this.emit("stateChange",u,e),this.debug?.(`state change: | ||
from ${Ae(u)} | ||
to ${Ae(e)}`)}createWebSocket(e){let t=new Q(`wss://${e}?v=4`,Boolean(this.debug));return t.on("error",this.onChildError),t.once("open",this.onWsOpen),t.on("packet",this.onWsPacket),t.once("close",this.onWsClose),t.on("debug",this.onWsDebug),t}onChildError(e){this.emit("error",e)}onWsOpen(){if(this.state.code===0){let e={op:k.VoiceOpcodes.Identify,d:{server_id:this.state.connectionOptions.serverId,user_id:this.state.connectionOptions.userId,session_id:this.state.connectionOptions.sessionId,token:this.state.connectionOptions.token}};this.state.ws.sendPacket(e),this.state={...this.state,code:1}}else if(this.state.code===5){let e={op:k.VoiceOpcodes.Resume,d:{server_id:this.state.connectionOptions.serverId,session_id:this.state.connectionOptions.sessionId,token:this.state.connectionOptions.token}};this.state.ws.sendPacket(e)}}onWsClose({code:e}){(e===4015||e<4e3)&&this.state.code===4?this.state={...this.state,code:5,ws:this.createWebSocket(this.state.connectionOptions.endpoint)}:this.state.code!==6&&(this.destroy(),this.emit("close",e))}onUdpClose(){this.state.code===4&&(this.state={...this.state,code:5,ws:this.createWebSocket(this.state.connectionOptions.endpoint)})}onWsPacket(e){if(e.op===k.VoiceOpcodes.Hello&&this.state.code!==6)this.state.ws.setHeartbeatInterval(e.d.heartbeat_interval);else if(e.op===k.VoiceOpcodes.Ready&&this.state.code===1){let{ip:t,port:s,ssrc:n,modes:o}=e.d,u=new X({ip:t,port:s});u.on("error",this.onChildError),u.on("debug",this.onUdpDebug),u.once("close",this.onUdpClose),u.performIPDiscovery(n).then(a=>{this.state.code===2&&(this.state.ws.sendPacket({op:k.VoiceOpcodes.SelectProtocol,d:{protocol:"udp",data:{address:a.ip,port:a.port,mode:mt(o)}}}),this.state={...this.state,code:3})}).catch(a=>this.emit("error",a)),this.state={...this.state,code:2,udp:u,connectionData:{ssrc:n}}}else if(e.op===k.VoiceOpcodes.SessionDescription&&this.state.code===3){let{mode:t,secret_key:s}=e.d;this.state={...this.state,code:4,connectionData:{...this.state.connectionData,encryptionMode:t,secretKey:new Uint8Array(s),sequence:Ce(16),timestamp:Ce(32),nonce:0,nonceBuffer:Buffer.alloc(24),speaking:!1,packetsPlayed:0}}}else e.op===k.VoiceOpcodes.Resumed&&this.state.code===5&&(this.state={...this.state,code:4},this.state.connectionData.speaking=!1)}onWsDebug(e){this.debug?.(`[WS] ${e}`)}onUdpDebug(e){this.debug?.(`[UDP] ${e}`)}prepareAudioPacket(e){let t=this.state;if(t.code===4)return t.preparedPacket=this.createAudioPacket(e,t.connectionData),t.preparedPacket}dispatchAudio(){let e=this.state;return e.code!==4?!1:typeof e.preparedPacket!="undefined"?(this.playAudioPacket(e.preparedPacket),e.preparedPacket=void 0,!0):!1}playAudioPacket(e){let t=this.state;if(t.code!==4)return;let{connectionData:s}=t;s.packetsPlayed++,s.sequence++,s.timestamp+=lt,s.sequence>=2**16&&(s.sequence=0),s.timestamp>=2**32&&(s.timestamp=0),this.setSpeaking(!0),t.udp.send(e)}setSpeaking(e){let t=this.state;t.code===4&&t.connectionData.speaking!==e&&(t.connectionData.speaking=e,t.ws.sendPacket({op:k.VoiceOpcodes.Speaking,d:{speaking:e?1:0,delay:0,ssrc:t.connectionData.ssrc}}))}createAudioPacket(e,t){let s=Buffer.alloc(12);s[0]=128,s[1]=120;let{sequence:n,timestamp:o,ssrc:u}=t;return s.writeUIntBE(n,2,2),s.writeUIntBE(o,4,4),s.writeUIntBE(u,8,4),s.copy(Pe,0,0,12),Buffer.concat([s,...this.encryptOpusPacket(e,t)])}encryptOpusPacket(e,t){let{secretKey:s,encryptionMode:n}=t;if(n==="xsalsa20_poly1305_lite")return t.nonce++,t.nonce>ft&&(t.nonce=0),t.nonceBuffer.writeUInt32BE(t.nonce,0),[C.close(e,t.nonceBuffer,s),t.nonceBuffer.slice(0,4)];if(n==="xsalsa20_poly1305_suffix"){let o=C.random(24,t.nonceBuffer);return[C.close(e,o,s),o]}return[C.close(e,Pe,s)]}};function Ce(i){return Math.floor(Math.random()*2**i)}function Ae(i){return JSON.stringify({...i,ws:Reflect.has(i,"ws"),udp:Reflect.has(i,"udp")})}function mt(i){let e=i.find(t=>ht.includes(t));if(!e)throw new Error(`No compatible encryption modes. Available include: ${i.join(", ")}`);return e}var Oe=h(require("tiny-typed-emitter"));var $=h(require("discord-api-types/voice/v4"));var Ee=h(require("node:stream"));var N=class extends Error{constructor(e,t){super(e.message);r(this,"resource");this.resource=t,this.name=e.name,this.stack=e.stack}};var W=class{constructor(e,t){r(this,"connection");r(this,"player");this.connection=e,this.player=t}unsubscribe(){this.connection.onSubscriptionRemoved(this),this.player.unsubscribe(this)}};var we=h(require("tiny-typed-emitter")),O=Buffer.from([248,255,254]),x;(function(s){s.Pause="pause",s.Play="play",s.Stop="stop"})(x||(x={}));var d;(function(o){o.Idle="idle",o.Buffering="buffering",o.Paused="paused",o.Playing="playing",o.AutoPaused="autopaused"})(d||(d={}));var H=class extends we.TypedEmitter{constructor(e={}){super();r(this,"_state");r(this,"subscribers",[]);r(this,"behaviors");r(this,"debug");this._state={status:d.Idle},this.behaviors={noSubscriber:x.Pause,maxMissedFrames:5,...e.behaviors},this.debug=e.debug===!1?null:t=>this.emit("debug",t)}get playable(){return this.subscribers.filter(({connection:e})=>e.state.status===c.Ready).map(({connection:e})=>e)}subscribe(e){let t=this.subscribers.find(s=>s.connection===e);if(!t){let s=new W(e,this);return this.subscribers.push(s),setImmediate(()=>this.emit("subscribe",s)),s}return t}unsubscribe(e){let t=this.subscribers.indexOf(e),s=t!==-1;return s&&(this.subscribers.splice(t,1),e.connection.setSpeaking(!1),this.emit("unsubscribe",e)),s}get state(){return this._state}set state(e){let t=this._state,s=Reflect.get(e,"resource");t.status!==d.Idle&&t.resource!==s&&(t.resource.playStream.on("error",g),t.resource.playStream.off("error",t.onStreamError),t.resource.audioPlayer=void 0,t.resource.playStream.destroy(),t.resource.playStream.read()),t.status===d.Buffering&&(e.status!==d.Buffering||e.resource!==t.resource)&&(t.resource.playStream.off("end",t.onFailureCallback),t.resource.playStream.off("close",t.onFailureCallback),t.resource.playStream.off("finish",t.onFailureCallback),t.resource.playStream.off("readable",t.onReadableCallback)),e.status===d.Idle&&(this._signalStopSpeaking(),he(this)),s&&fe(this);let n=t.status!==d.Idle&&e.status===d.Playing&&t.resource!==e.resource;this._state=e,this.emit("stateChange",t,this._state),(t.status!==e.status||n)&&this.emit(e.status,t,this._state),this.debug?.(`state change: | ||
from ${xe(t)} | ||
to ${xe(e)}`)}play(e){if(e.ended)throw new Error("Cannot play a resource that has already ended.");if(e.audioPlayer){if(e.audioPlayer===this)return;throw new Error("Resource is already being played by another audio player.")}e.audioPlayer=this;let t=s=>{this.state.status!==d.Idle&&this.emit("error",new N(s,this.state.resource)),this.state.status!==d.Idle&&this.state.resource===e&&(this.state={status:d.Idle})};if(e.playStream.once("error",t),e.started)this.state={status:d.Playing,missedFrames:0,playbackDuration:0,resource:e,onStreamError:t};else{let s=()=>{this.state.status===d.Buffering&&this.state.resource===e&&(this.state={status:d.Playing,missedFrames:0,playbackDuration:0,resource:e,onStreamError:t})},n=()=>{this.state.status===d.Buffering&&this.state.resource===e&&(this.state={status:d.Idle})};e.playStream.once("readable",s),e.playStream.once("end",n),e.playStream.once("close",n),e.playStream.once("finish",n),this.state={status:d.Buffering,resource:e,onReadableCallback:s,onFailureCallback:n,onStreamError:t}}}pause(e=!0){return this.state.status!==d.Playing?!1:(this.state={...this.state,status:d.Paused,silencePacketsRemaining:e?5:0},!0)}unpause(){return this.state.status!==d.Paused?!1:(this.state={...this.state,status:d.Playing,missedFrames:0},!0)}stop(e=!1){return this.state.status===d.Idle?!1:(e||this.state.resource.silencePaddingFrames===0?this.state={status:d.Idle}:this.state.resource.silenceRemaining===-1&&(this.state.resource.silenceRemaining=this.state.resource.silencePaddingFrames),!0)}checkPlayable(){let e=this._state;return e.status===d.Idle||e.status===d.Buffering?!1:e.resource.readable?!0:(this.state={status:d.Idle},!1)}_stepDispatch(){let e=this._state;e.status===d.Idle||e.status===d.Buffering||this.playable.forEach(t=>t.dispatchAudio())}_stepPrepare(){let e=this._state;if(e.status===d.Idle||e.status===d.Buffering)return;let t=this.playable;if(e.status===d.AutoPaused&&t.length>0&&(this.state={...e,status:d.Playing,missedFrames:0}),e.status===d.Paused||e.status===d.AutoPaused){e.silencePacketsRemaining>0&&(e.silencePacketsRemaining--,this._preparePacket(O,t,e),e.silencePacketsRemaining===0&&this._signalStopSpeaking());return}if(t.length===0)if(this.behaviors.noSubscriber===x.Pause){this.state={...e,status:d.AutoPaused,silencePacketsRemaining:5};return}else this.behaviors.noSubscriber===x.Stop&&this.stop(!0);let s=e.resource.read();e.status===d.Playing&&(s?(this._preparePacket(s,t,e),e.missedFrames=0):(this._preparePacket(O,t,e),e.missedFrames++,e.missedFrames>=this.behaviors.maxMissedFrames&&this.stop()))}_signalStopSpeaking(){return this.subscribers.forEach(({connection:e})=>e.setSpeaking(!1))}_preparePacket(e,t,s){s.playbackDuration+=20,t.forEach(n=>n.prepareAudioPacket(e))}};function xe(i){return JSON.stringify({...i,resource:Reflect.has(i,"resource"),stepTimeout:Reflect.has(i,"stepTimeout")})}function De(i){return new H(i)}var I;(function(s){s[s.Manual=0]="Manual",s[s.AfterSilence=1]="AfterSilence",s[s.AfterInactivity=2]="AfterInactivity"})(I||(I={}));function ie(){return{end:{behavior:0}}}var J=class extends Ee.Readable{constructor({end:e,...t}){super({...t,objectMode:!0});r(this,"end");r(this,"endTimeout");this.end=e}push(e){return e&&(this.end.behavior===2||this.end.behavior===1&&(e.compare(O)!==0||typeof this.endTimeout=="undefined"))&&this.renewEndTimeout(this.end),super.push(e)}renewEndTimeout(e){this.endTimeout&&clearTimeout(this.endTimeout),this.endTimeout=setTimeout(()=>this.push(null),e.duration)}_read(){}};var Re=h(require("tiny-typed-emitter")),se=class extends Re.TypedEmitter{constructor(){super();r(this,"users");r(this,"speakingTimeouts");this.users=new Map,this.speakingTimeouts=new Map}onPacket(e){let t=this.speakingTimeouts.get(e);t?clearTimeout(t):(this.users.set(e,Date.now()),this.emit("start",e)),this.startTimeout(e)}startTimeout(e){this.speakingTimeouts.set(e,setTimeout(()=>{this.emit("end",e),this.speakingTimeouts.delete(e),this.users.delete(e)},se.DELAY))}},T=se;r(T,"DELAY",100);var Ve=h(require("tiny-typed-emitter")),L=class extends Ve.TypedEmitter{constructor(){super();r(this,"map");this.map=new Map}update(e){let t=this.map.get(e.audioSSRC),s={...this.map.get(e.audioSSRC),...e};this.map.set(e.audioSSRC,s),t||this.emit("create",s),this.emit("update",t,s)}get(e){if(typeof e=="number")return this.map.get(e);for(let t of this.map.values())if(t.userId===e)return t}delete(e){if(typeof e=="number"){let t=this.map.get(e);return t&&(this.map.delete(e),this.emit("delete",t)),t}for(let[t,s]of this.map.entries())if(s.userId===e)return this.map.delete(t),this.emit("delete",s),s}};var q=class{constructor(e){r(this,"voiceConnection");r(this,"ssrcMap");r(this,"subscriptions");r(this,"connectionData");r(this,"speaking");this.voiceConnection=e,this.ssrcMap=new L,this.speaking=new T,this.subscriptions=new Map,this.connectionData={},this.onWsPacket=this.onWsPacket.bind(this),this.onUdpMessage=this.onUdpMessage.bind(this)}onWsPacket(e){e.op===$.VoiceOpcodes.ClientDisconnect&&typeof e.d?.user_id=="string"?this.ssrcMap.delete(e.d.user_id):e.op===$.VoiceOpcodes.Speaking&&typeof e.d?.user_id=="string"&&typeof e.d?.ssrc=="number"?this.ssrcMap.update({userId:e.d.user_id,audioSSRC:e.d.ssrc}):e.op===$.VoiceOpcodes.ClientConnect&&typeof e.d?.user_id=="string"&&typeof e.d?.audio_ssrc=="number"&&this.ssrcMap.update({userId:e.d.user_id,audioSSRC:e.d.audio_ssrc,videoSSRC:e.d.video_ssrc===0?void 0:e.d.video_ssrc})}decrypt(e,t,s,n){let o;t==="xsalsa20_poly1305_lite"?(e.copy(s,0,e.length-4),o=e.length-4):t==="xsalsa20_poly1305_suffix"?(e.copy(s,0,e.length-24),o=e.length-24):e.copy(s,0,0,12);let u=C.open(e.slice(12,o),s,n);if(!!u)return Buffer.from(u)}parsePacket(e,t,s,n){let o=this.decrypt(e,t,s,n);if(!!o){if(o[0]===190&&o[1]===222&&o.length>4){let u=o.readUInt16BE(2),a=4;for(let D=0;D<u;D++){let E=o[a];a++,E!==0&&(a+=1+(E>>4))}let P=o.readUInt8(a);(P===0||P===2)&&a++,o=o.slice(a)}return o}}onUdpMessage(e){if(e.length<=8)return;let t=e.readUInt32BE(8),s=this.ssrcMap.get(t);if(!s)return;this.speaking.onPacket(s.userId);let n=this.subscriptions.get(s.userId);if(!!n&&this.connectionData.encryptionMode&&this.connectionData.nonceBuffer&&this.connectionData.secretKey){let o=this.parsePacket(e,this.connectionData.encryptionMode,this.connectionData.nonceBuffer,this.connectionData.secretKey);o?n.push(o):n.destroy(new Error("Failed to parse packet"))}}subscribe(e,t){let s=this.subscriptions.get(e);if(s)return s;let n=new J({...ie(),...t});return n.once("close",()=>this.subscriptions.delete(e)),this.subscriptions.set(e,n),n}};var c;(function(o){o.Signalling="signalling",o.Connecting="connecting",o.Ready="ready",o.Disconnected="disconnected",o.Destroyed="destroyed"})(c||(c={}));var y;(function(n){n[n.WebSocketClose=0]="WebSocketClose",n[n.AdapterUnavailable=1]="AdapterUnavailable",n[n.EndpointRemoved=2]="EndpointRemoved",n[n.Manual=3]="Manual"})(y||(y={}));var K=class extends Oe.TypedEmitter{constructor(e,{debug:t,adapterCreator:s}){super();r(this,"rejoinAttempts");r(this,"_state");r(this,"joinConfig");r(this,"packets");r(this,"receiver");r(this,"debug");this.debug=t?o=>this.emit("debug",o):null,this.rejoinAttempts=0,this.receiver=new q(this),this.onNetworkingClose=this.onNetworkingClose.bind(this),this.onNetworkingStateChange=this.onNetworkingStateChange.bind(this),this.onNetworkingError=this.onNetworkingError.bind(this),this.onNetworkingDebug=this.onNetworkingDebug.bind(this);let n=s({onVoiceServerUpdate:o=>this.addServerPacket(o),onVoiceStateUpdate:o=>this.addStatePacket(o),destroy:()=>this.destroy(!1)});this._state={status:c.Signalling,adapter:n},this.packets={server:void 0,state:void 0},this.joinConfig=e}get state(){return this._state}set state(e){let t=this._state,s=Reflect.get(t,"networking"),n=Reflect.get(e,"networking"),o=Reflect.get(t,"subscription"),u=Reflect.get(e,"subscription");if(s!==n&&(s&&(s.on("error",g),s.off("debug",this.onNetworkingDebug),s.off("error",this.onNetworkingError),s.off("close",this.onNetworkingClose),s.off("stateChange",this.onNetworkingStateChange),s.destroy()),n&&this.updateReceiveBindings(n.state,s?.state)),e.status===c.Ready)this.rejoinAttempts=0;else if(e.status===c.Destroyed)for(let a of this.receiver.subscriptions.values())a.destroyed||a.destroy();t.status!==c.Destroyed&&e.status===c.Destroyed&&t.adapter.destroy(),this._state=e,o&&o!==u&&o.unsubscribe(),this.emit("stateChange",t,e),t.status!==e.status&&this.emit(e.status,t,e)}addServerPacket(e){this.packets.server=e,e.endpoint?this.configureNetworking():this.state.status!==c.Destroyed&&(this.state={...this.state,status:c.Disconnected,reason:2})}addStatePacket(e){this.packets.state=e,typeof e.self_deaf!="undefined"&&(this.joinConfig.selfDeaf=e.self_deaf),typeof e.self_mute!="undefined"&&(this.joinConfig.selfMute=e.self_mute),e.channel_id&&(this.joinConfig.channelId=e.channel_id)}updateReceiveBindings(e,t){let s=Reflect.get(t??{},"ws"),n=Reflect.get(e,"ws"),o=Reflect.get(t??{},"udp"),u=Reflect.get(e,"udp");s!==n&&(s?.off("packet",this.receiver.onWsPacket),n?.on("packet",this.receiver.onWsPacket)),o!==u&&(o?.off("message",this.receiver.onUdpMessage),u?.on("message",this.receiver.onUdpMessage)),this.receiver.connectionData=Reflect.get(e,"connectionData")??{}}configureNetworking(){let{server:e,state:t}=this.packets;if(!e||!t||this.state.status===c.Destroyed||!e.endpoint)return;let s=new te({endpoint:e.endpoint,serverId:e.guild_id,token:e.token,sessionId:t.session_id,userId:t.user_id},Boolean(this.debug));s.once("close",this.onNetworkingClose),s.on("stateChange",this.onNetworkingStateChange),s.on("error",this.onNetworkingError),s.on("debug",this.onNetworkingDebug),this.state={...this.state,status:c.Connecting,networking:s}}onNetworkingClose(e){this.state.status!==c.Destroyed&&(e===4014?this.state={...this.state,status:c.Disconnected,reason:0,closeCode:e}:(this.state={...this.state,status:c.Signalling},this.rejoinAttempts++,this.state.adapter.sendPayload(R(this.joinConfig))||(this.state={...this.state,status:c.Disconnected,reason:1})))}onNetworkingStateChange(e,t){this.updateReceiveBindings(t,e),e.code!==t.code&&(this.state.status!==c.Connecting&&this.state.status!==c.Ready||(t.code===l.Ready?this.state={...this.state,status:c.Ready}:t.code!==l.Closed&&(this.state={...this.state,status:c.Connecting})))}onNetworkingError(e){this.emit("error",e)}onNetworkingDebug(e){this.debug?.(`[NW] ${e}`)}prepareAudioPacket(e){let t=this.state;if(t.status===c.Ready)return t.networking.prepareAudioPacket(e)}dispatchAudio(){let e=this.state;if(e.status===c.Ready)return e.networking.dispatchAudio()}playOpusPacket(e){let t=this.state;if(t.status===c.Ready)return t.networking.prepareAudioPacket(e),t.networking.dispatchAudio()}destroy(e=!0){if(this.state.status===c.Destroyed)throw new Error("Cannot destroy VoiceConnection - it has already been destroyed");B(this.joinConfig.guildId)===this&&de(this),e&&this.state.adapter.sendPayload(R({...this.joinConfig,channelId:null})),this.state={status:c.Destroyed}}disconnect(){return this.state.status===c.Destroyed||this.state.status===c.Signalling?!1:(this.joinConfig.channelId=null,this.state.adapter.sendPayload(R(this.joinConfig))?(this.state={adapter:this.state.adapter,reason:3,status:c.Disconnected},!0):(this.state={adapter:this.state.adapter,subscription:this.state.subscription,status:c.Disconnected,reason:1},!1))}rejoin(e){if(this.state.status===c.Destroyed)return!1;let t=this.state.status!==c.Ready;return t&&this.rejoinAttempts++,Object.assign(this.joinConfig,e),this.state.adapter.sendPayload(R(this.joinConfig))?(t&&(this.state={...this.state,status:c.Signalling}),!0):(this.state={adapter:this.state.adapter,subscription:this.state.subscription,status:c.Disconnected,reason:1},!1)}setSpeaking(e){return this.state.status!==c.Ready?!1:this.state.networking.setSpeaking(e)}subscribe(e){if(this.state.status===c.Destroyed)return;let t=e.subscribe(this);return this.state={...this.state,subscription:t},t}get ping(){return this.state.status===c.Ready&&this.state.networking.state.code===l.Ready?{ws:this.state.networking.state.ws.ping,udp:this.state.networking.state.udp.ping}:{ws:void 0,udp:void 0}}onSubscriptionRemoved(e){this.state.status!==c.Destroyed&&this.state.subscription===e&&(this.state={...this.state,subscription:void 0})}};function Ie(i,e){let t=R(i),s=B(i.guildId);if(s&&s.state.status!==c.Destroyed)return s.state.status===c.Disconnected?s.rejoin({channelId:i.channelId,selfDeaf:i.selfDeaf,selfMute:i.selfMute}):s.state.adapter.sendPayload(t)||(s.state={...s.state,status:c.Disconnected,reason:1}),s;let n=new K(i,e);return ue(n),n.state.status!==c.Destroyed&&(n.state.adapter.sendPayload(t)||(n.state={...n.state,status:c.Disconnected,reason:1})),n}function gt(i){let e={selfDeaf:!0,selfMute:!1,group:"default",...i};return Ie(e,{adapterCreator:i.adapterCreator,debug:i.debug})}var v=h(require("prism-media")),_e=["-analyzeduration","0","-loglevel","0","-f","s16le","-ar","48000","-ac","2"],Me=["-analyzeduration","0","-loglevel","0","-acodec","libopus","-f","opus","-ar","48000","-ac","2"],p;(function(o){o.Arbitrary="arbitrary",o.Raw="raw",o.OggOpus="ogg/opus",o.WebmOpus="webm/opus",o.Opus="opus"})(p||(p={}));var b;(function(a){a.FFmpegPCM="ffmpeg pcm",a.FFmpegOgg="ffmpeg ogg",a.OpusEncoder="opus encoder",a.OpusDecoder="opus decoder",a.OggOpusDemuxer="ogg/opus demuxer",a.WebmOpusDemuxer="webm/opus demuxer",a.InlineVolume="volume transformer"})(b||(b={}));var Ue=class{constructor(e){r(this,"edges",[]);r(this,"type");this.type=e}addEdge(e){this.edges.push({...e,from:this})}},Be=new Map;for(let i of Object.values(p))Be.set(i,new Ue(i));function m(i){let e=Be.get(i);if(!e)throw new Error(`Node type '${i}' does not exist!`);return e}m(p.Raw).addEdge({type:b.OpusEncoder,to:m(p.Opus),cost:1.5,transformer:()=>new v.default.opus.Encoder({rate:48e3,channels:2,frameSize:960})});m(p.Opus).addEdge({type:b.OpusDecoder,to:m(p.Raw),cost:1.5,transformer:()=>new v.default.opus.Decoder({rate:48e3,channels:2,frameSize:960})});m(p.OggOpus).addEdge({type:b.OggOpusDemuxer,to:m(p.Opus),cost:1,transformer:()=>new v.default.opus.OggDemuxer});m(p.WebmOpus).addEdge({type:b.WebmOpusDemuxer,to:m(p.Opus),cost:1,transformer:()=>new v.default.opus.WebmDemuxer});var oe={type:b.FFmpegPCM,to:m(p.Raw),cost:2,transformer:i=>new v.default.FFmpeg({args:typeof i=="string"?["-i",i,..._e]:_e})};m(p.Arbitrary).addEdge(oe);m(p.OggOpus).addEdge(oe);m(p.WebmOpus).addEdge(oe);m(p.Raw).addEdge({type:b.InlineVolume,to:m(p.Raw),cost:.5,transformer:()=>new v.default.VolumeTransformer({type:"s16le"})});function yt(){try{return v.default.FFmpeg.getInfo().output.includes("--enable-libopus")}catch{}return!1}if(yt()){let i={type:b.FFmpegOgg,to:m(p.OggOpus),cost:2,transformer:e=>new v.default.FFmpeg({args:typeof e=="string"?["-i",e,...Me]:Me})};m(p.Arbitrary).addEdge(i),m(p.OggOpus).addEdge(i),m(p.WebmOpus).addEdge(i)}function Ne(i,e,t=m(p.Opus),s=[],n=5){if(i===t&&e(s))return{cost:0};if(n===0)return{cost:1/0};let o;for(let u of i.edges){if(o&&u.cost>o.cost)continue;let a=Ne(u.to,e,t,[...s,u],n-1),P=u.cost+a.cost;(!o||P<o.cost)&&(o={cost:P,edge:u,next:a})}return o??{cost:1/0}}function bt(i){let e=[],t=i;for(;t?.edge;)e.push(t.edge),t=t.next;return e}function We(i,e){return bt(Ne(m(i),e))}var Te=h(require("node:stream"));var A=h(require("prism-media"));var j=class{constructor(e,t,s,n){r(this,"playStream");r(this,"edges");r(this,"metadata");r(this,"volume");r(this,"encoder");r(this,"audioPlayer");r(this,"playbackDuration",0);r(this,"started",!1);r(this,"silencePaddingFrames");r(this,"silenceRemaining",-1);this.edges=e,this.playStream=t.length>1?(0,Te.pipeline)(t,g):t[0],this.metadata=s,this.silencePaddingFrames=n;for(let o of t)o instanceof A.default.VolumeTransformer?this.volume=o:o instanceof A.default.opus.Encoder&&(this.encoder=o);this.playStream.once("readable",()=>this.started=!0)}get readable(){if(this.silenceRemaining===0)return!1;let e=this.playStream.readable;return e||(this.silenceRemaining===-1&&(this.silenceRemaining=this.silencePaddingFrames),this.silenceRemaining!==0)}get ended(){return this.playStream.readableEnded||this.playStream.destroyed||this.silenceRemaining===0}read(){if(this.silenceRemaining===0)return null;if(this.silenceRemaining>0)return this.silenceRemaining--,O;let e=this.playStream.read();return e&&(this.playbackDuration+=20),e}},St=i=>i.some(e=>e.type===b.InlineVolume),kt=()=>!0;function vt(i){return i instanceof A.default.opus.Encoder?{streamType:p.Opus,hasVolume:!1}:i instanceof A.default.opus.Decoder?{streamType:p.Raw,hasVolume:!1}:i instanceof A.default.VolumeTransformer?{streamType:p.Raw,hasVolume:!0}:i instanceof A.default.opus.OggDemuxer?{streamType:p.Opus,hasVolume:!1}:i instanceof A.default.opus.WebmDemuxer?{streamType:p.Opus,hasVolume:!1}:{streamType:p.Arbitrary,hasVolume:!1}}function je(i,e={}){let t=e.inputType,s=Boolean(e.inlineVolume);if(typeof i=="string")t=p.Arbitrary;else if(typeof t=="undefined"){let u=vt(i);t=u.streamType,s=s&&!u.hasVolume}let n=We(t,s?St:kt);if(n.length===0){if(typeof i=="string")throw new Error(`Invalid pipeline constructed for string resource '${i}'`);return new j([],[i],e.metadata??null,e.silencePaddingFrames??5)}let o=n.map(u=>u.transformer(i));return typeof i!="string"&&o.unshift(i),new j(n,o,e.metadata??null,e.silencePaddingFrames??5)}var F=h(require("node:path")),Ge=h(require("prism-media"));function Ct(){let i=[],e=t=>i.push(`- ${t}: ${At(t)}`);i.push("Core Dependencies"),e("@discordjs/voice"),e("prism-media"),i.push(""),i.push("Opus Libraries"),e("@discordjs/opus"),e("opusscript"),i.push(""),i.push("Encryption Libraries"),e("sodium"),e("libsodium-wrappers"),e("tweetnacl"),i.push(""),i.push("FFmpeg");try{let t=Ge.default.FFmpeg.getInfo();i.push(`- version: ${t.version}`),i.push(`- libopus: ${t.output.includes("--enable-libopus")?"yes":"no"}`)}catch{i.push("- not found")}return["-".repeat(50),...i,"-".repeat(50)].join(` | ||
`)}function He(i,e,t){if(t===0)return;let s=(0,F.resolve)(i,"./package.json");try{let n=require(s);if(n.name!==e)throw new Error("package.json does not match");return n}catch{return He((0,F.resolve)(i,".."),e,t-1)}}function At(i){try{return(i==="@discordjs/voice"?Fe():He((0,F.dirname)(require.resolve(i)),i,3))?.version??"not found"}catch{return"not found"}}function Je(i){let e=new AbortController,t=setTimeout(()=>e.abort(),i);return e.signal.addEventListener("abort",()=>clearTimeout(t)),[e,e.signal]}var Le=h(require("node:events"));async function wt(i,e,t){if(i.state.status!==e){let[s,n]=typeof t=="number"?Je(t):[void 0,t];try{await(0,Le.once)(i,e,{signal:n})}finally{s?.abort()}}return i}var $e=h(require("node:stream")),ne=h(require("prism-media"));function qe(i){let e=i.readUInt8(9),t=i.readUInt32LE(12);return e===2&&t===48e3}function xt(i,e=1024,t=qe){return new Promise((s,n)=>{i.readableObjectMode&&n(new Error("Cannot probe a readable stream in object mode")),i.readableEnded&&n(new Error("Cannot probe a stream that has ended"));let o=Buffer.alloc(0),u,a=S=>{i.off("data",z),i.off("close",_),i.off("end",_),i.pause(),u=S,i.readableEnded?s({stream:$e.Readable.from(o),type:S}):(o.length>0&&i.push(o),s({stream:i,type:S}))},P=S=>Ke=>{t(Ke)&&a(S)},D=new ne.default.opus.WebmDemuxer;D.once("error",g),D.on("head",P(p.WebmOpus));let E=new ne.default.opus.OggDemuxer;E.once("error",g),E.on("head",P(p.OggOpus));let _=()=>{u||a(p.Arbitrary)},z=S=>{o=Buffer.concat([o,S]),D.write(S),E.write(S),o.length>=e&&(i.off("data",z),i.pause(),process.nextTick(_))};i.once("error",n),i.on("data",z),i.once("close",_),i.once("end",_)})}0&&(module.exports={AudioPlayer,AudioPlayerError,AudioPlayerStatus,AudioReceiveStream,AudioResource,EndBehaviorType,NoSubscriberBehavior,PlayerSubscription,SSRCMap,SpeakingMap,StreamType,VoiceConnection,VoiceConnectionDisconnectReason,VoiceConnectionStatus,VoiceReceiver,createAudioPlayer,createAudioResource,createDefaultAudioReceiveStreamOptions,demuxProbe,entersState,generateDependencyReport,getGroups,getVoiceConnection,getVoiceConnections,joinVoiceChannel,validateDiscordOpusHead}); | ||
//# sourceMappingURL=index.js.map | ||
`)},g={open:K,close:K,random:K};(async()=>{for(let i of Object.keys(be))try{let e=require(i);i==="libsodium-wrappers"&&e.ready&&await e.ready,Object.assign(g,be[i](e));break}catch{}})();var p=()=>{};var Se=require("tiny-typed-emitter"),pt=2,lt=48e3/100*pt,ft=2**32-1,ht=["xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"];var Ce=Buffer.alloc(24);function ke(i){return JSON.stringify({...i,ws:Reflect.has(i,"ws"),udp:Reflect.has(i,"udp")})}function mt(i){let e=i.find(t=>ht.includes(t));if(!e)throw new Error(`No compatible encryption modes. Available include: ${i.join(", ")}`);return e}function Ae(i){return Math.floor(Math.random()*2**i)}var z=class extends Se.TypedEmitter{constructor(e,t){super();r(this,"_state");r(this,"debug");this.onWsOpen=this.onWsOpen.bind(this),this.onChildError=this.onChildError.bind(this),this.onWsPacket=this.onWsPacket.bind(this),this.onWsClose=this.onWsClose.bind(this),this.onWsDebug=this.onWsDebug.bind(this),this.onUdpDebug=this.onUdpDebug.bind(this),this.onUdpClose=this.onUdpClose.bind(this),this.debug=t?o=>this.emit("debug",o):null,this._state={code:0,ws:this.createWebSocket(e.endpoint),connectionOptions:e}}destroy(){this.state={code:6}}get state(){return this._state}set state(e){let t=Reflect.get(this._state,"ws"),o=Reflect.get(e,"ws");t&&t!==o&&(t.off("debug",this.onWsDebug),t.on("error",p),t.off("error",this.onChildError),t.off("open",this.onWsOpen),t.off("packet",this.onWsPacket),t.off("close",this.onWsClose),t.destroy());let s=Reflect.get(this._state,"udp"),n=Reflect.get(e,"udp");s&&s!==n&&(s.on("error",p),s.off("error",this.onChildError),s.off("close",this.onUdpClose),s.off("debug",this.onUdpDebug),s.destroy());let a=this._state;this._state=e,this.emit("stateChange",a,e),this.debug?.(`state change: | ||
from ${ke(a)} | ||
to ${ke(e)}`)}createWebSocket(e){let t=new q(`wss://${e}?v=4`,Boolean(this.debug));return t.on("error",this.onChildError),t.once("open",this.onWsOpen),t.on("packet",this.onWsPacket),t.once("close",this.onWsClose),t.on("debug",this.onWsDebug),t}onChildError(e){this.emit("error",e)}onWsOpen(){if(this.state.code===0){let e={op:f.VoiceOpcodes.Identify,d:{server_id:this.state.connectionOptions.serverId,user_id:this.state.connectionOptions.userId,session_id:this.state.connectionOptions.sessionId,token:this.state.connectionOptions.token}};this.state.ws.sendPacket(e),this.state={...this.state,code:1}}else if(this.state.code===5){let e={op:f.VoiceOpcodes.Resume,d:{server_id:this.state.connectionOptions.serverId,session_id:this.state.connectionOptions.sessionId,token:this.state.connectionOptions.token}};this.state.ws.sendPacket(e)}}onWsClose({code:e}){(e===4015||e<4e3)&&this.state.code===4?this.state={...this.state,code:5,ws:this.createWebSocket(this.state.connectionOptions.endpoint)}:this.state.code!==6&&(this.destroy(),this.emit("close",e))}onUdpClose(){this.state.code===4&&(this.state={...this.state,code:5,ws:this.createWebSocket(this.state.connectionOptions.endpoint)})}onWsPacket(e){if(e.op===f.VoiceOpcodes.Hello&&this.state.code!==6)this.state.ws.setHeartbeatInterval(e.d.heartbeat_interval);else if(e.op===f.VoiceOpcodes.Ready&&this.state.code===1){let{ip:t,port:o,ssrc:s,modes:n}=e.d,a=new L({ip:t,port:o});a.on("error",this.onChildError),a.on("debug",this.onUdpDebug),a.once("close",this.onUdpClose),a.performIPDiscovery(s).then(d=>{this.state.code===2&&(this.state.ws.sendPacket({op:f.VoiceOpcodes.SelectProtocol,d:{protocol:"udp",data:{address:d.ip,port:d.port,mode:mt(n)}}}),this.state={...this.state,code:3})}).catch(d=>this.emit("error",d)),this.state={...this.state,code:2,udp:a,connectionData:{ssrc:s}}}else if(e.op===f.VoiceOpcodes.SessionDescription&&this.state.code===3){let{mode:t,secret_key:o}=e.d;this.state={...this.state,code:4,connectionData:{...this.state.connectionData,encryptionMode:t,secretKey:new Uint8Array(o),sequence:Ae(16),timestamp:Ae(32),nonce:0,nonceBuffer:Buffer.alloc(24),speaking:!1,packetsPlayed:0}}}else e.op===f.VoiceOpcodes.Resumed&&this.state.code===5&&(this.state={...this.state,code:4},this.state.connectionData.speaking=!1)}onWsDebug(e){this.debug?.(`[WS] ${e}`)}onUdpDebug(e){this.debug?.(`[UDP] ${e}`)}prepareAudioPacket(e){let t=this.state;if(t.code===4)return t.preparedPacket=this.createAudioPacket(e,t.connectionData),t.preparedPacket}dispatchAudio(){let e=this.state;return e.code!==4?!1:typeof e.preparedPacket!="undefined"?(this.playAudioPacket(e.preparedPacket),e.preparedPacket=void 0,!0):!1}playAudioPacket(e){let t=this.state;if(t.code!==4)return;let{connectionData:o}=t;o.packetsPlayed++,o.sequence++,o.timestamp+=lt,o.sequence>=2**16&&(o.sequence=0),o.timestamp>=2**32&&(o.timestamp=0),this.setSpeaking(!0),t.udp.send(e)}setSpeaking(e){let t=this.state;t.code===4&&t.connectionData.speaking!==e&&(t.connectionData.speaking=e,t.ws.sendPacket({op:f.VoiceOpcodes.Speaking,d:{speaking:e?1:0,delay:0,ssrc:t.connectionData.ssrc}}))}createAudioPacket(e,t){let o=Buffer.alloc(12);o[0]=128,o[1]=120;let{sequence:s,timestamp:n,ssrc:a}=t;return o.writeUIntBE(s,2,2),o.writeUIntBE(n,4,4),o.writeUIntBE(a,8,4),o.copy(Ce,0,0,12),Buffer.concat([o,...this.encryptOpusPacket(e,t)])}encryptOpusPacket(e,t){let{secretKey:o,encryptionMode:s}=t;if(s==="xsalsa20_poly1305_lite")return t.nonce++,t.nonce>ft&&(t.nonce=0),t.nonceBuffer.writeUInt32BE(t.nonce,0),[g.close(e,t.nonceBuffer,o),t.nonceBuffer.slice(0,4)];if(s==="xsalsa20_poly1305_suffix"){let n=g.random(24,t.nonceBuffer);return[g.close(e,n,o),n]}return[g.close(e,Ce,o)]}};var Re=require("tiny-typed-emitter");var F=require("discord-api-types/voice/v4");var xe=require("stream");var R=class extends Error{constructor(e,t){super(e.message);r(this,"resource");this.resource=t,this.name=e.name,this.stack=e.stack}};var O=class{constructor(e,t){r(this,"connection");r(this,"player");this.connection=e,this.player=t}unsubscribe(){this.connection.onSubscriptionRemoved(this),this.player.unsubscribe(this)}};var Pe=require("tiny-typed-emitter"),P=Buffer.from([248,255,254]),Y=(o=>(o.Pause="pause",o.Play="play",o.Stop="stop",o))(Y||{}),X=(n=>(n.Idle="idle",n.Buffering="buffering",n.Paused="paused",n.Playing="playing",n.AutoPaused="autopaused",n))(X||{});function ve(i){return JSON.stringify({...i,resource:Reflect.has(i,"resource"),stepTimeout:Reflect.has(i,"stepTimeout")})}var B=class extends Pe.TypedEmitter{constructor(e={}){super();r(this,"_state");r(this,"subscribers",[]);r(this,"behaviors");r(this,"debug");this._state={status:"idle"},this.behaviors={noSubscriber:"pause",maxMissedFrames:5,...e.behaviors},this.debug=e.debug===!1?null:t=>this.emit("debug",t)}get playable(){return this.subscribers.filter(({connection:e})=>e.state.status==="ready").map(({connection:e})=>e)}subscribe(e){let t=this.subscribers.find(o=>o.connection===e);if(!t){let o=new O(e,this);return this.subscribers.push(o),setImmediate(()=>this.emit("subscribe",o)),o}return t}unsubscribe(e){let t=this.subscribers.indexOf(e),o=t!==-1;return o&&(this.subscribers.splice(t,1),e.connection.setSpeaking(!1),this.emit("unsubscribe",e)),o}get state(){return this._state}set state(e){let t=this._state,o=Reflect.get(e,"resource");t.status!=="idle"&&t.resource!==o&&(t.resource.playStream.on("error",p),t.resource.playStream.off("error",t.onStreamError),t.resource.audioPlayer=void 0,t.resource.playStream.destroy(),t.resource.playStream.read()),t.status==="buffering"&&(e.status!=="buffering"||e.resource!==t.resource)&&(t.resource.playStream.off("end",t.onFailureCallback),t.resource.playStream.off("close",t.onFailureCallback),t.resource.playStream.off("finish",t.onFailureCallback),t.resource.playStream.off("readable",t.onReadableCallback)),e.status==="idle"&&(this._signalStopSpeaking(),le(this)),o&&pe(this);let s=t.status!=="idle"&&e.status==="playing"&&t.resource!==e.resource;this._state=e,this.emit("stateChange",t,this._state),(t.status!==e.status||s)&&this.emit(e.status,t,this._state),this.debug?.(`state change: | ||
from ${ve(t)} | ||
to ${ve(e)}`)}play(e){if(e.ended)throw new Error("Cannot play a resource that has already ended.");if(e.audioPlayer){if(e.audioPlayer===this)return;throw new Error("Resource is already being played by another audio player.")}e.audioPlayer=this;let t=o=>{this.state.status!=="idle"&&this.emit("error",new R(o,this.state.resource)),this.state.status!=="idle"&&this.state.resource===e&&(this.state={status:"idle"})};if(e.playStream.once("error",t),e.started)this.state={status:"playing",missedFrames:0,playbackDuration:0,resource:e,onStreamError:t};else{let o=()=>{this.state.status==="buffering"&&this.state.resource===e&&(this.state={status:"playing",missedFrames:0,playbackDuration:0,resource:e,onStreamError:t})},s=()=>{this.state.status==="buffering"&&this.state.resource===e&&(this.state={status:"idle"})};e.playStream.once("readable",o),e.playStream.once("end",s),e.playStream.once("close",s),e.playStream.once("finish",s),this.state={status:"buffering",resource:e,onReadableCallback:o,onFailureCallback:s,onStreamError:t}}}pause(e=!0){return this.state.status!=="playing"?!1:(this.state={...this.state,status:"paused",silencePacketsRemaining:e?5:0},!0)}unpause(){return this.state.status!=="paused"?!1:(this.state={...this.state,status:"playing",missedFrames:0},!0)}stop(e=!1){return this.state.status==="idle"?!1:(e||this.state.resource.silencePaddingFrames===0?this.state={status:"idle"}:this.state.resource.silenceRemaining===-1&&(this.state.resource.silenceRemaining=this.state.resource.silencePaddingFrames),!0)}checkPlayable(){let e=this._state;return e.status==="idle"||e.status==="buffering"?!1:e.resource.readable?!0:(this.state={status:"idle"},!1)}_stepDispatch(){let e=this._state;e.status==="idle"||e.status==="buffering"||this.playable.forEach(t=>t.dispatchAudio())}_stepPrepare(){let e=this._state;if(e.status==="idle"||e.status==="buffering")return;let t=this.playable;if(e.status==="autopaused"&&t.length>0&&(this.state={...e,status:"playing",missedFrames:0}),e.status==="paused"||e.status==="autopaused"){e.silencePacketsRemaining>0&&(e.silencePacketsRemaining--,this._preparePacket(P,t,e),e.silencePacketsRemaining===0&&this._signalStopSpeaking());return}if(t.length===0)if(this.behaviors.noSubscriber==="pause"){this.state={...e,status:"autopaused",silencePacketsRemaining:5};return}else this.behaviors.noSubscriber==="stop"&&this.stop(!0);let o=e.resource.read();e.status==="playing"&&(o?(this._preparePacket(o,t,e),e.missedFrames=0):(this._preparePacket(P,t,e),e.missedFrames++,e.missedFrames>=this.behaviors.maxMissedFrames&&this.stop()))}_signalStopSpeaking(){return this.subscribers.forEach(({connection:e})=>e.setSpeaking(!1))}_preparePacket(e,t,o){o.playbackDuration+=20,t.forEach(s=>s.prepareAudioPacket(e))}};function we(i){return new B(i)}var Ve=(o=>(o[o.Manual=0]="Manual",o[o.AfterSilence=1]="AfterSilence",o[o.AfterInactivity=2]="AfterInactivity",o))(Ve||{});function Z(){return{end:{behavior:0}}}var U=class extends xe.Readable{constructor({end:e,...t}){super({...t,objectMode:!0});r(this,"end");r(this,"endTimeout");this.end=e}push(e){return e&&(this.end.behavior===2||this.end.behavior===1&&(e.compare(P)!==0||typeof this.endTimeout=="undefined"))&&this.renewEndTimeout(this.end),super.push(e)}renewEndTimeout(e){this.endTimeout&&clearTimeout(this.endTimeout),this.endTimeout=setTimeout(()=>this.push(null),e.duration)}_read(){}};var De=require("tiny-typed-emitter"),Q=class extends De.TypedEmitter{constructor(){super();r(this,"users");r(this,"speakingTimeouts");this.users=new Map,this.speakingTimeouts=new Map}onPacket(e){let t=this.speakingTimeouts.get(e);t?clearTimeout(t):(this.users.set(e,Date.now()),this.emit("start",e)),this.startTimeout(e)}startTimeout(e){this.speakingTimeouts.set(e,setTimeout(()=>{this.emit("end",e),this.speakingTimeouts.delete(e),this.users.delete(e)},Q.DELAY))}},I=Q;r(I,"DELAY",100);var Ee=require("tiny-typed-emitter"),W=class extends Ee.TypedEmitter{constructor(){super();r(this,"map");this.map=new Map}update(e){let t=this.map.get(e.audioSSRC),o={...this.map.get(e.audioSSRC),...e};this.map.set(e.audioSSRC,o),t||this.emit("create",o),this.emit("update",t,o)}get(e){if(typeof e=="number")return this.map.get(e);for(let t of this.map.values())if(t.userId===e)return t}delete(e){if(typeof e=="number"){let t=this.map.get(e);return t&&(this.map.delete(e),this.emit("delete",t)),t}for(let[t,o]of this.map.entries())if(o.userId===e)return this.map.delete(t),this.emit("delete",o),o}};var j=class{constructor(e){r(this,"voiceConnection");r(this,"ssrcMap");r(this,"subscriptions");r(this,"connectionData");r(this,"speaking");this.voiceConnection=e,this.ssrcMap=new W,this.speaking=new I,this.subscriptions=new Map,this.connectionData={},this.onWsPacket=this.onWsPacket.bind(this),this.onUdpMessage=this.onUdpMessage.bind(this)}onWsPacket(e){e.op===F.VoiceOpcodes.ClientDisconnect&&typeof e.d?.user_id=="string"?this.ssrcMap.delete(e.d.user_id):e.op===F.VoiceOpcodes.Speaking&&typeof e.d?.user_id=="string"&&typeof e.d?.ssrc=="number"?this.ssrcMap.update({userId:e.d.user_id,audioSSRC:e.d.ssrc}):e.op===F.VoiceOpcodes.ClientConnect&&typeof e.d?.user_id=="string"&&typeof e.d?.audio_ssrc=="number"&&this.ssrcMap.update({userId:e.d.user_id,audioSSRC:e.d.audio_ssrc,videoSSRC:e.d.video_ssrc===0?void 0:e.d.video_ssrc})}decrypt(e,t,o,s){let n;t==="xsalsa20_poly1305_lite"?(e.copy(o,0,e.length-4),n=e.length-4):t==="xsalsa20_poly1305_suffix"?(e.copy(o,0,e.length-24),n=e.length-24):e.copy(o,0,0,12);let a=g.open(e.slice(12,n),o,s);if(!!a)return Buffer.from(a)}parsePacket(e,t,o,s){let n=this.decrypt(e,t,o,s);if(!!n){if(n[0]===190&&n[1]===222&&n.length>4){let a=n.readUInt16BE(2),d=4;for(let S=0;S<a;S++){let C=n[d];d++,C!==0&&(d+=1+(C>>4))}let m=n.readUInt8(d);(m===0||m===2)&&d++,n=n.slice(d)}return n}}onUdpMessage(e){if(e.length<=8)return;let t=e.readUInt32BE(8),o=this.ssrcMap.get(t);if(!o)return;this.speaking.onPacket(o.userId);let s=this.subscriptions.get(o.userId);if(!!s&&this.connectionData.encryptionMode&&this.connectionData.nonceBuffer&&this.connectionData.secretKey){let n=this.parsePacket(e,this.connectionData.encryptionMode,this.connectionData.nonceBuffer,this.connectionData.secretKey);n?s.push(n):s.destroy(new Error("Failed to parse packet"))}}subscribe(e,t){let o=this.subscriptions.get(e);if(o)return o;let s=new U({...Z(),...t});return s.once("close",()=>this.subscriptions.delete(e)),this.subscriptions.set(e,s),s}};var M=(n=>(n.Signalling="signalling",n.Connecting="connecting",n.Ready="ready",n.Disconnected="disconnected",n.Destroyed="destroyed",n))(M||{}),ee=(s=>(s[s.WebSocketClose=0]="WebSocketClose",s[s.AdapterUnavailable=1]="AdapterUnavailable",s[s.EndpointRemoved=2]="EndpointRemoved",s[s.Manual=3]="Manual",s))(ee||{}),G=class extends Re.TypedEmitter{constructor(e,{debug:t,adapterCreator:o}){super();r(this,"rejoinAttempts");r(this,"_state");r(this,"joinConfig");r(this,"packets");r(this,"receiver");r(this,"debug");this.debug=t?n=>this.emit("debug",n):null,this.rejoinAttempts=0,this.receiver=new j(this),this.onNetworkingClose=this.onNetworkingClose.bind(this),this.onNetworkingStateChange=this.onNetworkingStateChange.bind(this),this.onNetworkingError=this.onNetworkingError.bind(this),this.onNetworkingDebug=this.onNetworkingDebug.bind(this);let s=o({onVoiceServerUpdate:n=>this.addServerPacket(n),onVoiceStateUpdate:n=>this.addStatePacket(n),destroy:()=>this.destroy(!1)});this._state={status:"signalling",adapter:s},this.packets={server:void 0,state:void 0},this.joinConfig=e}get state(){return this._state}set state(e){let t=this._state,o=Reflect.get(t,"networking"),s=Reflect.get(e,"networking"),n=Reflect.get(t,"subscription"),a=Reflect.get(e,"subscription");if(o!==s&&(o&&(o.on("error",p),o.off("debug",this.onNetworkingDebug),o.off("error",this.onNetworkingError),o.off("close",this.onNetworkingClose),o.off("stateChange",this.onNetworkingStateChange),o.destroy()),s&&this.updateReceiveBindings(s.state,o?.state)),e.status==="ready")this.rejoinAttempts=0;else if(e.status==="destroyed")for(let d of this.receiver.subscriptions.values())d.destroyed||d.destroy();t.status!=="destroyed"&&e.status==="destroyed"&&t.adapter.destroy(),this._state=e,n&&n!==a&&n.unsubscribe(),this.emit("stateChange",t,e),t.status!==e.status&&this.emit(e.status,t,e)}addServerPacket(e){this.packets.server=e,e.endpoint?this.configureNetworking():this.state.status!=="destroyed"&&(this.state={...this.state,status:"disconnected",reason:2})}addStatePacket(e){this.packets.state=e,typeof e.self_deaf!="undefined"&&(this.joinConfig.selfDeaf=e.self_deaf),typeof e.self_mute!="undefined"&&(this.joinConfig.selfMute=e.self_mute),e.channel_id&&(this.joinConfig.channelId=e.channel_id)}updateReceiveBindings(e,t){let o=Reflect.get(t??{},"ws"),s=Reflect.get(e,"ws"),n=Reflect.get(t??{},"udp"),a=Reflect.get(e,"udp");o!==s&&(o?.off("packet",this.receiver.onWsPacket),s?.on("packet",this.receiver.onWsPacket)),n!==a&&(n?.off("message",this.receiver.onUdpMessage),a?.on("message",this.receiver.onUdpMessage)),this.receiver.connectionData=Reflect.get(e,"connectionData")??{}}configureNetworking(){let{server:e,state:t}=this.packets;if(!e||!t||this.state.status==="destroyed"||!e.endpoint)return;let o=new z({endpoint:e.endpoint,serverId:e.guild_id,token:e.token,sessionId:t.session_id,userId:t.user_id},Boolean(this.debug));o.once("close",this.onNetworkingClose),o.on("stateChange",this.onNetworkingStateChange),o.on("error",this.onNetworkingError),o.on("debug",this.onNetworkingDebug),this.state={...this.state,status:"connecting",networking:o}}onNetworkingClose(e){this.state.status!=="destroyed"&&(e===4014?this.state={...this.state,status:"disconnected",reason:0,closeCode:e}:(this.state={...this.state,status:"signalling"},this.rejoinAttempts++,this.state.adapter.sendPayload(k(this.joinConfig))||(this.state={...this.state,status:"disconnected",reason:1})))}onNetworkingStateChange(e,t){this.updateReceiveBindings(t,e),e.code!==t.code&&(this.state.status!=="connecting"&&this.state.status!=="ready"||(t.code===4?this.state={...this.state,status:"ready"}:t.code!==6&&(this.state={...this.state,status:"connecting"})))}onNetworkingError(e){this.emit("error",e)}onNetworkingDebug(e){this.debug?.(`[NW] ${e}`)}prepareAudioPacket(e){let t=this.state;if(t.status==="ready")return t.networking.prepareAudioPacket(e)}dispatchAudio(){let e=this.state;if(e.status==="ready")return e.networking.dispatchAudio()}playOpusPacket(e){let t=this.state;if(t.status==="ready")return t.networking.prepareAudioPacket(e),t.networking.dispatchAudio()}destroy(e=!0){if(this.state.status==="destroyed")throw new Error("Cannot destroy VoiceConnection - it has already been destroyed");E(this.joinConfig.guildId)===this&&ae(this),e&&this.state.adapter.sendPayload(k({...this.joinConfig,channelId:null})),this.state={status:"destroyed"}}disconnect(){return this.state.status==="destroyed"||this.state.status==="signalling"?!1:(this.joinConfig.channelId=null,this.state.adapter.sendPayload(k(this.joinConfig))?(this.state={adapter:this.state.adapter,reason:3,status:"disconnected"},!0):(this.state={adapter:this.state.adapter,subscription:this.state.subscription,status:"disconnected",reason:1},!1))}rejoin(e){if(this.state.status==="destroyed")return!1;let t=this.state.status!=="ready";return t&&this.rejoinAttempts++,Object.assign(this.joinConfig,e),this.state.adapter.sendPayload(k(this.joinConfig))?(t&&(this.state={...this.state,status:"signalling"}),!0):(this.state={adapter:this.state.adapter,subscription:this.state.subscription,status:"disconnected",reason:1},!1)}setSpeaking(e){return this.state.status!=="ready"?!1:this.state.networking.setSpeaking(e)}subscribe(e){if(this.state.status==="destroyed")return;let t=e.subscribe(this);return this.state={...this.state,subscription:t},t}get ping(){return this.state.status==="ready"&&this.state.networking.state.code===4?{ws:this.state.networking.state.ws.ping,udp:this.state.networking.state.udp.ping}:{ws:void 0,udp:void 0}}onSubscriptionRemoved(e){this.state.status!=="destroyed"&&this.state.subscription===e&&(this.state={...this.state,subscription:void 0})}};function Oe(i,e){let t=k(i),o=E(i.guildId);if(o&&o.state.status!=="destroyed")return o.state.status==="disconnected"?o.rejoin({channelId:i.channelId,selfDeaf:i.selfDeaf,selfMute:i.selfMute}):o.state.adapter.sendPayload(t)||(o.state={...o.state,status:"disconnected",reason:1}),o;let s=new G(i,e);return ce(s),s.state.status!=="destroyed"&&(s.state.adapter.sendPayload(t)||(s.state={...s.state,status:"disconnected",reason:1})),s}function gt(i){let e={selfDeaf:!0,selfMute:!1,group:"default",...i};return Oe(e,{adapterCreator:i.adapterCreator,debug:i.debug})}var h=V(require("prism-media")),Ie=["-analyzeduration","0","-loglevel","0","-f","s16le","-ar","48000","-ac","2"],Te=["-analyzeduration","0","-loglevel","0","-acodec","libopus","-f","opus","-ar","48000","-ac","2"],v=(n=>(n.Arbitrary="arbitrary",n.Raw="raw",n.OggOpus="ogg/opus",n.WebmOpus="webm/opus",n.Opus="opus",n))(v||{});var _e=class{constructor(e){r(this,"edges",[]);r(this,"type");this.type=e}addEdge(e){this.edges.push({...e,from:this})}},Ne=new Map;for(let i of Object.values(v))Ne.set(i,new _e(i));function u(i){let e=Ne.get(i);if(!e)throw new Error(`Node type '${i}' does not exist!`);return e}u("raw").addEdge({type:"opus encoder",to:u("opus"),cost:1.5,transformer:()=>new h.default.opus.Encoder({rate:48e3,channels:2,frameSize:960})});u("opus").addEdge({type:"opus decoder",to:u("raw"),cost:1.5,transformer:()=>new h.default.opus.Decoder({rate:48e3,channels:2,frameSize:960})});u("ogg/opus").addEdge({type:"ogg/opus demuxer",to:u("opus"),cost:1,transformer:()=>new h.default.opus.OggDemuxer});u("webm/opus").addEdge({type:"webm/opus demuxer",to:u("opus"),cost:1,transformer:()=>new h.default.opus.WebmDemuxer});var te={type:"ffmpeg pcm",to:u("raw"),cost:2,transformer:i=>new h.default.FFmpeg({args:typeof i=="string"?["-i",i,...Ie]:Ie})};u("arbitrary").addEdge(te);u("ogg/opus").addEdge(te);u("webm/opus").addEdge(te);u("raw").addEdge({type:"volume transformer",to:u("raw"),cost:.5,transformer:()=>new h.default.VolumeTransformer({type:"s16le"})});function yt(){try{return h.default.FFmpeg.getInfo().output.includes("--enable-libopus")}catch{}return!1}if(yt()){let i={type:"ffmpeg ogg",to:u("ogg/opus"),cost:2,transformer:e=>new h.default.FFmpeg({args:typeof e=="string"?["-i",e,...Te]:Te})};u("arbitrary").addEdge(i),u("ogg/opus").addEdge(i),u("webm/opus").addEdge(i)}function Be(i,e,t=u("opus"),o=[],s=5){if(i===t&&e(o))return{cost:0};if(s===0)return{cost:1/0};let n;for(let a of i.edges){if(n&&a.cost>n.cost)continue;let d=Be(a.to,e,t,[...o,a],s-1),m=a.cost+d.cost;(!n||m<n.cost)&&(n={cost:m,edge:a,next:d})}return n??{cost:1/0}}function bt(i){let e=[],t=i;for(;t?.edge;)e.push(t.edge),t=t.next;return e}function Me(i,e){return bt(Be(u(i),e))}var Ue=require("stream");var y=V(require("prism-media"));var T=class{constructor(e,t,o,s){r(this,"playStream");r(this,"edges");r(this,"metadata");r(this,"volume");r(this,"encoder");r(this,"audioPlayer");r(this,"playbackDuration",0);r(this,"started",!1);r(this,"silencePaddingFrames");r(this,"silenceRemaining",-1);this.edges=e,this.playStream=t.length>1?(0,Ue.pipeline)(t,p):t[0],this.metadata=o,this.silencePaddingFrames=s;for(let n of t)n instanceof y.default.VolumeTransformer?this.volume=n:n instanceof y.default.opus.Encoder&&(this.encoder=n);this.playStream.once("readable",()=>this.started=!0)}get readable(){if(this.silenceRemaining===0)return!1;let e=this.playStream.readable;return e||(this.silenceRemaining===-1&&(this.silenceRemaining=this.silencePaddingFrames),this.silenceRemaining!==0)}get ended(){return this.playStream.readableEnded||this.playStream.destroyed||this.silenceRemaining===0}read(){if(this.silenceRemaining===0)return null;if(this.silenceRemaining>0)return this.silenceRemaining--,P;let e=this.playStream.read();return e&&(this.playbackDuration+=20),e}},St=i=>i.some(e=>e.type==="volume transformer"),Ct=()=>!0;function kt(i){return i instanceof y.default.opus.Encoder?{streamType:"opus",hasVolume:!1}:i instanceof y.default.opus.Decoder?{streamType:"raw",hasVolume:!1}:i instanceof y.default.VolumeTransformer?{streamType:"raw",hasVolume:!0}:i instanceof y.default.opus.OggDemuxer?{streamType:"opus",hasVolume:!1}:i instanceof y.default.opus.WebmDemuxer?{streamType:"opus",hasVolume:!1}:{streamType:"arbitrary",hasVolume:!1}}function We(i,e={}){let t=e.inputType,o=Boolean(e.inlineVolume);if(typeof i=="string")t="arbitrary";else if(typeof t=="undefined"){let a=kt(i);t=a.streamType,o=o&&!a.hasVolume}let s=Me(t,o?St:Ct);if(s.length===0){if(typeof i=="string")throw new Error(`Invalid pipeline constructed for string resource '${i}'`);return new T([],[i],e.metadata??null,e.silencePaddingFrames??5)}let n=s.map(a=>a.transformer(i));return typeof i!="string"&&n.unshift(i),new T(s,n,e.metadata??null,e.silencePaddingFrames??5)}var _=require("path"),je=V(require("prism-media"));function Ge(i,e,t){if(t===0)return;let o=(0,_.resolve)(i,"./package.json");try{let s=require(o);if(s.name!==e)throw new Error("package.json does not match");return s}catch{return Ge((0,_.resolve)(i,".."),e,t-1)}}function Pt(i){try{return(i==="@discordjs/voice"?Fe():Ge((0,_.dirname)(require.resolve(i)),i,3))?.version??"not found"}catch{return"not found"}}function vt(){let i=[],e=t=>i.push(`- ${t}: ${Pt(t)}`);i.push("Core Dependencies"),e("@discordjs/voice"),e("prism-media"),i.push(""),i.push("Opus Libraries"),e("@discordjs/opus"),e("opusscript"),i.push(""),i.push("Encryption Libraries"),e("sodium"),e("libsodium-wrappers"),e("tweetnacl"),i.push(""),i.push("FFmpeg");try{let t=je.default.FFmpeg.getInfo();i.push(`- version: ${t.version}`),i.push(`- libopus: ${t.output.includes("--enable-libopus")?"yes":"no"}`)}catch{i.push("- not found")}return["-".repeat(50),...i,"-".repeat(50)].join(` | ||
`)}function He(i){let e=new AbortController,t=setTimeout(()=>e.abort(),i);return e.signal.addEventListener("abort",()=>clearTimeout(t)),[e,e.signal]}var Je=require("events");async function wt(i,e,t){if(i.state.status!==e){let[o,s]=typeof t=="number"?He(t):[void 0,t];try{await(0,Je.once)(i,e,{signal:s})}finally{o?.abort()}}return i}var Le=require("stream"),ie=V(require("prism-media"));function $e(i){let e=i.readUInt8(9),t=i.readUInt32LE(12);return e===2&&t===48e3}function xt(i,e=1024,t=$e){return new Promise((o,s)=>{if(i.readableObjectMode)return s(new Error("Cannot probe a readable stream in object mode"));if(i.readableEnded)return s(new Error("Cannot probe a stream that has ended"));let n=Buffer.alloc(0),a,d=l=>{i.off("data",H),i.off("close",w),i.off("end",w),i.pause(),a=l,i.readableEnded?o({stream:Le.Readable.from(n),type:l}):(n.length>0&&i.push(n),o({stream:i,type:l}))},m=l=>qe=>{t(qe)&&d(l)},S=new ie.default.opus.WebmDemuxer;S.once("error",p),S.on("head",m("webm/opus"));let C=new ie.default.opus.OggDemuxer;C.once("error",p),C.on("head",m("ogg/opus"));let w=()=>{a||d("arbitrary")},H=l=>{n=Buffer.concat([n,l]),S.write(l),C.write(l),n.length>=e&&(i.off("data",H),i.pause(),process.nextTick(w))};i.once("error",s),i.on("data",H),i.once("close",w),i.once("end",w)})}module.exports=it(Vt);0&&(module.exports={AudioPlayer,AudioPlayerError,AudioPlayerStatus,AudioReceiveStream,AudioResource,EndBehaviorType,NoSubscriberBehavior,PlayerSubscription,SSRCMap,SpeakingMap,StreamType,VoiceConnection,VoiceConnectionDisconnectReason,VoiceConnectionStatus,VoiceReceiver,createAudioPlayer,createAudioResource,createDefaultAudioReceiveStreamOptions,demuxProbe,entersState,generateDependencyReport,getGroups,getVoiceConnection,getVoiceConnections,joinVoiceChannel,validateDiscordOpusHead}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@discordjs/voice", | ||
"version": "0.7.5", | ||
"description": "Implementation of the Discord Voice API for Node.js", | ||
"version": "0.8.0", | ||
"description": "Implementation of the Discord Voice API for node.js", | ||
"scripts": { | ||
"pretest": "npm run build", | ||
"test": "jest --pass-with-no-tests", | ||
"test:ci": "jest --no-stack-trace --verbose --pass-with-no-tests", | ||
"prebuild": "npm run lint", | ||
"build": "tsup", | ||
"postbuild": "node scripts/postbuild.mjs", | ||
"lint": "eslint src --ext mjs,js,ts", | ||
"lint:fix": "eslint src --ext mjs,js,ts --fix", | ||
"format": "prettier --write **/*.{ts,js,json,yml,yaml}", | ||
"prepare": "is-ci || husky install", | ||
"build": "tsup && node scripts/postbuild.mjs", | ||
"test": "jest --pass-with-no-tests --collect-coverage", | ||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts", | ||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix", | ||
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs", | ||
"//prepublishOnly": "npm run lint && npm run test", | ||
"release": "standard-version --preset angular" | ||
"prepublishOnly": "yarn build && yarn lint && yarn test", | ||
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'" | ||
}, | ||
@@ -34,3 +28,9 @@ "main": "./dist/index.js", | ||
], | ||
"author": "Amish Shah <amish@shah.gg>", | ||
"contributors": [ | ||
"Crawl <icrawltogo@gmail.com>", | ||
"Amish Shah <amishshah.2k@gmail.com>", | ||
"SpaceEEC <spaceeec@yahoo.com>", | ||
"Vlad Frangu <kingdgrizzle@gmail.com>", | ||
"Antonio Roman <kyradiscord@gmail.com>" | ||
], | ||
"license": "Apache-2.0", | ||
@@ -46,46 +46,41 @@ "keywords": [ | ||
"type": "git", | ||
"url": "git+https://github.com/discordjs/voice.git" | ||
"url": "git+https://github.com/discordjs/discord.js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/discordjs/voice/issues" | ||
"url": "https://github.com/discordjs/discord.js/issues" | ||
}, | ||
"homepage": "https://github.com/discordjs/voice", | ||
"homepage": "https://discord.js.org", | ||
"dependencies": { | ||
"@types/ws": "^8.2.0", | ||
"discord-api-types": "^0.24.0", | ||
"discord-api-types": "^0.26.1", | ||
"prism-media": "^1.3.2", | ||
"tiny-typed-emitter": "^2.1.0", | ||
"tslib": "^2.3.1", | ||
"ws": "^8.2.3" | ||
"ws": "^8.4.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@babel/core": "^7.16.12", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/preset-typescript": "^7.16.0", | ||
"@commitlint/cli": "^14.1.0", | ||
"@commitlint/config-angular": "^14.1.0", | ||
"@discordjs/ts-docgen": "^0.3.2", | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^16.11.7", | ||
"@typescript-eslint/eslint-plugin": "^5.3.1", | ||
"@typescript-eslint/parser": "^5.3.1", | ||
"eslint": "^8.2.0", | ||
"eslint-config-marine": "^9.0.6", | ||
"@typescript-eslint/eslint-plugin": "^5.10.0", | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"eslint": "^8.7.0", | ||
"eslint-config-marine": "^9.3.2", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "^7.0.4", | ||
"is-ci": "^3.0.1", | ||
"jest": "^27.3.1", | ||
"jest-websocket-mock": "^2.2.1", | ||
"lint-staged": "^11.2.6", | ||
"mock-socket": "^9.0.7", | ||
"jest": "^27.4.7", | ||
"jest-websocket-mock": "^2.3.0", | ||
"mock-socket": "^9.1.0", | ||
"prettier": "^2.4.1", | ||
"standard-version": "^9.3.2", | ||
"tsup": "^5.7.0", | ||
"typedoc": "^0.22.8", | ||
"typescript": "^4.4.4" | ||
"tsup": "^5.11.11", | ||
"tweetnacl": "^1.0.3", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.5.5" | ||
}, | ||
"engines": { | ||
"node": ">=16.0.0", | ||
"npm": ">=7.0.0" | ||
"node": ">=16.9.0" | ||
}, | ||
@@ -92,0 +87,0 @@ "publishConfig": { |
@@ -11,3 +11,3 @@ <div align="center"> | ||
<a href="https://www.npmjs.com/package/@discordjs/voice"><img src="https://img.shields.io/npm/dt/@discordjs/voice.svg?maxAge=3600" alt="npm downloads" /></a> | ||
<a href="https://github.com/discordjs/voice/actions"><img src="https://github.com/discordjs/voice/workflows/Tests/badge.svg" alt="Build status" /></a> | ||
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a> | ||
<a href="https://codecov.io/gh/discordjs/voice"><img src="https://codecov.io/gh/discordjs/voice/branch/main/graph/badge.svg" alt="Code coverage" /></a> | ||
@@ -24,3 +24,3 @@ <a href="https://www.patreon.com/discordjs"><img src="https://img.shields.io/badge/donate-patreon-F96854.svg" alt="Patreon" /></a> | ||
- Send and receive* audio in Discord voice-based channels | ||
- Send and receive\* audio in Discord voice-based channels | ||
- A strong focus on reliability and predictable behaviour | ||
@@ -30,7 +30,7 @@ - Horizontal scalability and libraries other than [discord.js](https://discord.js.org/) are supported with custom adapters | ||
\**Audio receive is not documented by Discord so stable support is not guaranteed* | ||
\*_Audio receive is not documented by Discord so stable support is not guaranteed_ | ||
## Installation | ||
**Node.js 16.0.0 or newer is required.** | ||
**Node.js 16.9.0 or newer is required.** | ||
@@ -71,5 +71,5 @@ ```sh-session | ||
- [Documentation](https://discord.js.org/#/docs/voice) | ||
- [Examples](https://github.com/discordjs/voice/tree/main/examples) | ||
- [Examples](https://github.com/discordjs/discord.js/tree/main/packages/voice/examples) | ||
- [discord.js Discord server](https://discord.gg/djs) | ||
- [GitHub](https://github.com/discordjs/voice) | ||
- [GitHub](https://github.com/discordjs/discord.js/tree/main/packages/voice) | ||
- [npm](https://www.npmjs.com/package/@discordjs/voice) | ||
@@ -81,3 +81,3 @@ | ||
[documentation](https://discord.js.org/#/docs/voice). | ||
See [the contribution guide](https://github.com/discordjs/voice/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. | ||
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. | ||
@@ -84,0 +84,0 @@ ## Help |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
469761
21
11
1887
2
+ Addeddiscord-api-types@0.26.1(transitive)
- Removeddiscord-api-types@0.24.0(transitive)
Updateddiscord-api-types@^0.26.1
Updatedws@^8.4.2