@discordjs/voice
Advanced tools
Comparing version 0.8.0 to 0.9.0-dev.1644537980.298b226
@@ -708,3 +708,3 @@ import { Readable, ReadableOptions } from 'node:stream'; | ||
*/ | ||
private lastHeatbeatSend; | ||
private lastHeartbeatSend; | ||
/** | ||
@@ -711,0 +711,0 @@ * The number of consecutively missed heartbeats. |
@@ -1,10 +0,10 @@ | ||
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. | ||
var ze=Object.create;var A=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?A(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var ne=i=>A(i,"__esModule",{value:!0}),r=(i,e)=>A(i,"name",{value:e,configurable:!0});var tt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),it=(i,e)=>{for(var t in e)A(i,t,{get:e[t],enumerable:!0})},re=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xe(e))!Qe.call(i,s)&&(t||s!=="default")&&A(i,s,{get:()=>e[s],enumerable:!(o=Ye(e,s))||o.enumerable});return i},I=(i,e)=>re(ne(A(i!=null?ze(Ze(i)):{},"default",!e&&i&&i.__esModule?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i),ot=(i=>(e,t)=>i&&i.get(e)||(t=re(ne({}),e,1),i&&i.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var a=(i,e,t)=>(et(i,typeof e!="symbol"?e+"":e,t),t);var je=tt((qi,Pt)=>{Pt.exports={name:"@discordjs/voice",version:"0.9.0-dev",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.17.0","@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.2","@typescript-eslint/parser":"^5.10.2",eslint:"^8.8.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.2",prettier:"^2.4.1",tsup:"^5.11.13",tweetnacl:"^1.0.3",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});var Dt={};it(Dt,{AudioPlayer:()=>N,AudioPlayerError:()=>w,AudioPlayerStatus:()=>Z,AudioReceiveStream:()=>B,AudioResource:()=>R,EndBehaviorType:()=>Ee,NoSubscriberBehavior:()=>X,PlayerSubscription:()=>x,SSRCMap:()=>M,SpeakingMap:()=>D,StreamType:()=>E,VoiceConnection:()=>W,VoiceConnectionDisconnectReason:()=>te,VoiceConnectionStatus:()=>L,VoiceReceiver:()=>U,createAudioPlayer:()=>Ve,createAudioResource:()=>Fe,createDefaultAudioReceiveStreamOptions:()=>Q,demuxProbe:()=>Vt,entersState:()=>xt,generateDependencyReport:()=>wt,getGroups:()=>ce,getVoiceConnection:()=>_,getVoiceConnections:()=>j,joinVoiceChannel:()=>yt,validateDiscordOpusHead:()=>qe});var ae=require("discord-api-types/v9");function P(i){return{op:ae.GatewayOpcodes.VoiceStateUpdate,d:{guild_id:i.guildId,channel_id:i.channelId,self_deaf:i.selfDeaf,self_mute:i.selfMute}}}r(P,"createJoinVoiceChannelPayload");var T=new Map;T.set("default",new Map);function st(i){let e=T.get(i);if(e)return e;let t=new Map;return T.set(i,t),t}r(st,"getOrCreateGroup");function ce(){return T}r(ce,"getGroups");function j(i="default"){return T.get(i)}r(j,"getVoiceConnections");function _(i,e="default"){return j(e)?.get(i)}r(_,"getVoiceConnection");function de(i){return j(i.joinConfig.group)?.delete(i.joinConfig.guildId)}r(de,"untrackVoiceConnection");function ue(i){return st(i.joinConfig.group).set(i.joinConfig.guildId,i)}r(ue,"trackVoiceConnection");var nt=20,K,v=-1,S=[];function pe(){if(v===-1)return;v+=nt;let i=S.filter(e=>e.checkPlayable());i.forEach(e=>e._stepDispatch()),le(i)}r(pe,"audioCycleStep");function le(i){let e=i.shift();if(!e){v!==-1&&(K=setTimeout(()=>pe(),v-Date.now()));return}e._stepPrepare(),setImmediate(()=>le(i))}r(le,"prepareNextAudioFrame");function rt(i){return S.includes(i)}r(rt,"hasAudioPlayer");function fe(i){return rt(i)||(S.push(i),S.length===1&&(v=Date.now(),setImmediate(()=>pe()))),i}r(fe,"addAudioPlayer");function he(i){let e=S.indexOf(i);e!==-1&&(S.splice(e,1),S.length===0&&(v=-1,typeof K!="undefined"&&clearTimeout(K)))}r(he,"deleteAudioPlayer");var h=require("discord-api-types/voice/v4");var me=require("dgram"),ge=require("net"),ye=require("tiny-typed-emitter");function at(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 o=e.readUInt16BE(e.length-2);return{ip:t,port:o}}r(at,"parseLocalPacket");var ct=5e3,dt=12,ut=2**32-1,G=class extends ye.TypedEmitter{constructor(e,t=!1){super();a(this,"socket");a(this,"remote");a(this,"keepAlives");a(this,"keepAliveCounter",0);a(this,"keepAliveBuffer");a(this,"keepAliveInterval");a(this,"ping");a(this,"debug");this.socket=(0,me.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(),ct),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>=dt){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>ut&&(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=r(c=>{try{if(c.readUInt16BE(0)!==2)return;let u=at(c);this.socket.off("message",s),t(u)}catch{}},"listener");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)})}};r(G,"VoiceUDPSocket");var z=require("discord-api-types/voice/v4"),be=I(require("ws")),Se=require("tiny-typed-emitter"),H=class extends Se.TypedEmitter{constructor(e,t){super();a(this,"heartbeatInterval");a(this,"lastHeartbeatAck");a(this,"lastHeartbeatSend");a(this,"missedHeartbeats",0);a(this,"ping");a(this,"debug");a(this,"ws");this.ws=new be.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.lastHeartbeatSend=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===z.VoiceOpcodes.HeartbeatAck&&(this.lastHeartbeatAck=Date.now(),this.missedHeartbeats=0,this.ping=this.lastHeartbeatAck-this.lastHeartbeatSend),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.lastHeartbeatSend=Date.now(),this.missedHeartbeats++;let e=this.lastHeartbeatSend;return this.sendPacket({op:z.VoiceOpcodes.Heartbeat,d:e})}setHeartbeatInterval(e){typeof this.heartbeatInterval!="undefined"&&clearInterval(this.heartbeatInterval),e>0&&(this.heartbeatInterval=setInterval(()=>{this.lastHeartbeatSend!==0&&this.missedHeartbeats>=3&&(this.ws.close(),this.setHeartbeatInterval(-1)),this.sendHeartbeat()},e))}};r(H,"VoiceWebSocket");var Ce={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)})},Y=r(()=>{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. | ||
`)},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}); | ||
`)},"fallbackError"),y={open:Y,close:Y,random:Y};(async()=>{for(let i of Object.keys(Ce))try{let e=require(i);i==="libsodium-wrappers"&&e.ready&&await e.ready,Object.assign(y,Ce[i](e));break}catch{}})();var l=r(()=>{},"noop");var ke=require("tiny-typed-emitter"),lt=2,ft=48e3/100*lt,ht=2**32-1,mt=["xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"];var Ae=Buffer.alloc(24);function Pe(i){return JSON.stringify({...i,ws:Reflect.has(i,"ws"),udp:Reflect.has(i,"udp")})}r(Pe,"stringifyState");function gt(i){let e=i.find(t=>mt.includes(t));if(!e)throw new Error(`No compatible encryption modes. Available include: ${i.join(", ")}`);return e}r(gt,"chooseEncryptionMode");function ve(i){return Math.floor(Math.random()*2**i)}r(ve,"randomNBit");var J=class extends ke.TypedEmitter{constructor(e,t){super();a(this,"_state");a(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",l),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",l),s.off("error",this.onChildError),s.off("close",this.onUdpClose),s.off("debug",this.onUdpDebug),s.destroy());let c=this._state;this._state=e,this.emit("stateChange",c,e),this.debug?.(`state change: | ||
from ${Pe(c)} | ||
to ${Pe(e)}`)}createWebSocket(e){let t=new H(`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:h.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:h.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===h.VoiceOpcodes.Hello&&this.state.code!==6)this.state.ws.setHeartbeatInterval(e.d.heartbeat_interval);else if(e.op===h.VoiceOpcodes.Ready&&this.state.code===1){let{ip:t,port:o,ssrc:s,modes:n}=e.d,c=new G({ip:t,port:o});c.on("error",this.onChildError),c.on("debug",this.onUdpDebug),c.once("close",this.onUdpClose),c.performIPDiscovery(s).then(u=>{this.state.code===2&&(this.state.ws.sendPacket({op:h.VoiceOpcodes.SelectProtocol,d:{protocol:"udp",data:{address:u.ip,port:u.port,mode:gt(n)}}}),this.state={...this.state,code:3})}).catch(u=>this.emit("error",u)),this.state={...this.state,code:2,udp:c,connectionData:{ssrc:s}}}else if(e.op===h.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:ve(16),timestamp:ve(32),nonce:0,nonceBuffer:Buffer.alloc(24),speaking:!1,packetsPlayed:0}}}else e.op===h.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+=ft,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:h.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:c}=t;return o.writeUIntBE(s,2,2),o.writeUIntBE(n,4,4),o.writeUIntBE(c,8,4),o.copy(Ae,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>ht&&(t.nonce=0),t.nonceBuffer.writeUInt32BE(t.nonce,0),[y.close(e,t.nonceBuffer,o),t.nonceBuffer.slice(0,4)];if(s==="xsalsa20_poly1305_suffix"){let n=y.random(24,t.nonceBuffer);return[y.close(e,n,o),n]}return[y.close(e,Ae,o)]}};r(J,"Networking");var Ie=require("tiny-typed-emitter");var $=require("discord-api-types/voice/v4");var De=require("stream");var w=class extends Error{constructor(e,t){super(e.message);a(this,"resource");this.resource=t,this.name=e.name,this.stack=e.stack}};r(w,"AudioPlayerError");var x=class{constructor(e,t){a(this,"connection");a(this,"player");this.connection=e,this.player=t}unsubscribe(){this.connection.onSubscriptionRemoved(this),this.player.unsubscribe(this)}};r(x,"PlayerSubscription");var we=require("tiny-typed-emitter"),V=Buffer.from([248,255,254]),X=(o=>(o.Pause="pause",o.Play="play",o.Stop="stop",o))(X||{}),Z=(n=>(n.Idle="idle",n.Buffering="buffering",n.Paused="paused",n.Playing="playing",n.AutoPaused="autopaused",n))(Z||{});function xe(i){return JSON.stringify({...i,resource:Reflect.has(i,"resource"),stepTimeout:Reflect.has(i,"stepTimeout")})}r(xe,"stringifyState");var N=class extends we.TypedEmitter{constructor(e={}){super();a(this,"_state");a(this,"subscribers",[]);a(this,"behaviors");a(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 x(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",l),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(),he(this)),o&&fe(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 ${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=r(o=>{this.state.status!=="idle"&&this.emit("error",new w(o,this.state.resource)),this.state.status!=="idle"&&this.state.resource===e&&(this.state={status:"idle"})},"onStreamError");if(e.playStream.once("error",t),e.started)this.state={status:"playing",missedFrames:0,playbackDuration:0,resource:e,onStreamError:t};else{let o=r(()=>{this.state.status==="buffering"&&this.state.resource===e&&(this.state={status:"playing",missedFrames:0,playbackDuration:0,resource:e,onStreamError:t})},"onReadableCallback"),s=r(()=>{this.state.status==="buffering"&&this.state.resource===e&&(this.state={status:"idle"})},"onFailureCallback");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(V,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(V,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))}};r(N,"AudioPlayer");function Ve(i){return new N(i)}r(Ve,"createAudioPlayer");var Ee=(o=>(o[o.Manual=0]="Manual",o[o.AfterSilence=1]="AfterSilence",o[o.AfterInactivity=2]="AfterInactivity",o))(Ee||{});function Q(){return{end:{behavior:0}}}r(Q,"createDefaultAudioReceiveStreamOptions");var B=class extends De.Readable{constructor({end:e,...t}){super({...t,objectMode:!0});a(this,"end");a(this,"endTimeout");this.end=e}push(e){return e&&(this.end.behavior===2||this.end.behavior===1&&(e.compare(V)!==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(){}};r(B,"AudioReceiveStream");var Re=require("tiny-typed-emitter"),ee=class extends Re.TypedEmitter{constructor(){super();a(this,"users");a(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)},ee.DELAY))}},D=ee;r(D,"SpeakingMap"),a(D,"DELAY",100);var Oe=require("tiny-typed-emitter"),M=class extends Oe.TypedEmitter{constructor(){super();a(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}};r(M,"SSRCMap");var U=class{constructor(e){a(this,"voiceConnection");a(this,"ssrcMap");a(this,"subscriptions");a(this,"connectionData");a(this,"speaking");this.voiceConnection=e,this.ssrcMap=new M,this.speaking=new D,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,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 c=y.open(e.slice(12,n),o,s);if(!!c)return Buffer.from(c)}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 c=n.readUInt16BE(2),u=4;for(let C=0;C<c;C++){let k=n[u];u++,k!==0&&(u+=1+(k>>4))}let g=n.readUInt8(u);(g===0||g===2)&&u++,n=n.slice(u)}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 B({...Q(),...t});return s.once("close",()=>this.subscriptions.delete(e)),this.subscriptions.set(e,s),s}};r(U,"VoiceReceiver");var L=(n=>(n.Signalling="signalling",n.Connecting="connecting",n.Ready="ready",n.Disconnected="disconnected",n.Destroyed="destroyed",n))(L||{}),te=(s=>(s[s.WebSocketClose=0]="WebSocketClose",s[s.AdapterUnavailable=1]="AdapterUnavailable",s[s.EndpointRemoved=2]="EndpointRemoved",s[s.Manual=3]="Manual",s))(te||{}),W=class extends Ie.TypedEmitter{constructor(e,{debug:t,adapterCreator:o}){super();a(this,"rejoinAttempts");a(this,"_state");a(this,"joinConfig");a(this,"packets");a(this,"receiver");a(this,"debug");this.debug=t?n=>this.emit("debug",n):null,this.rejoinAttempts=0,this.receiver=new U(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"),c=Reflect.get(e,"subscription");if(o!==s&&(o&&(o.on("error",l),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 u of this.receiver.subscriptions.values())u.destroyed||u.destroy();t.status!=="destroyed"&&e.status==="destroyed"&&t.adapter.destroy(),this._state=e,n&&n!==c&&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"),c=Reflect.get(e,"udp");o!==s&&(o?.off("packet",this.receiver.onWsPacket),s?.on("packet",this.receiver.onWsPacket)),n!==c&&(n?.off("message",this.receiver.onUdpMessage),c?.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 J({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(P(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");_(this.joinConfig.guildId)===this&&de(this),e&&this.state.adapter.sendPayload(P({...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(P(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(P(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})}};r(W,"VoiceConnection");function Te(i,e){let t=P(i),o=_(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 W(i,e);return ue(s),s.state.status!=="destroyed"&&(s.state.adapter.sendPayload(t)||(s.state={...s.state,status:"disconnected",reason:1})),s}r(Te,"createVoiceConnection");function yt(i){let e={selfDeaf:!0,selfMute:!1,group:"default",...i};return Te(e,{adapterCreator:i.adapterCreator,debug:i.debug})}r(yt,"joinVoiceChannel");var m=I(require("prism-media")),_e=["-analyzeduration","0","-loglevel","0","-f","s16le","-ar","48000","-ac","2"],Ne=["-analyzeduration","0","-loglevel","0","-acodec","libopus","-f","opus","-ar","48000","-ac","2"],E=(n=>(n.Arbitrary="arbitrary",n.Raw="raw",n.OggOpus="ogg/opus",n.WebmOpus="webm/opus",n.Opus="opus",n))(E||{});var ie=class{constructor(e){a(this,"edges",[]);a(this,"type");this.type=e}addEdge(e){this.edges.push({...e,from:this})}};r(ie,"Node");var Be=new Map;for(let i of Object.values(E))Be.set(i,new ie(i));function p(i){let e=Be.get(i);if(!e)throw new Error(`Node type '${i}' does not exist!`);return e}r(p,"getNode");p("raw").addEdge({type:"opus encoder",to:p("opus"),cost:1.5,transformer:()=>new m.default.opus.Encoder({rate:48e3,channels:2,frameSize:960})});p("opus").addEdge({type:"opus decoder",to:p("raw"),cost:1.5,transformer:()=>new m.default.opus.Decoder({rate:48e3,channels:2,frameSize:960})});p("ogg/opus").addEdge({type:"ogg/opus demuxer",to:p("opus"),cost:1,transformer:()=>new m.default.opus.OggDemuxer});p("webm/opus").addEdge({type:"webm/opus demuxer",to:p("opus"),cost:1,transformer:()=>new m.default.opus.WebmDemuxer});var oe={type:"ffmpeg pcm",to:p("raw"),cost:2,transformer:i=>new m.default.FFmpeg({args:typeof i=="string"?["-i",i,..._e]:_e})};p("arbitrary").addEdge(oe);p("ogg/opus").addEdge(oe);p("webm/opus").addEdge(oe);p("raw").addEdge({type:"volume transformer",to:p("raw"),cost:.5,transformer:()=>new m.default.VolumeTransformer({type:"s16le"})});function bt(){try{return m.default.FFmpeg.getInfo().output.includes("--enable-libopus")}catch{}return!1}r(bt,"canEnableFFmpegOptimizations");if(bt()){let i={type:"ffmpeg ogg",to:p("ogg/opus"),cost:2,transformer:e=>new m.default.FFmpeg({args:typeof e=="string"?["-i",e,...Ne]:Ne})};p("arbitrary").addEdge(i),p("ogg/opus").addEdge(i),p("webm/opus").addEdge(i)}function Me(i,e,t=p("opus"),o=[],s=5){if(i===t&&e(o))return{cost:0};if(s===0)return{cost:1/0};let n;for(let c of i.edges){if(n&&c.cost>n.cost)continue;let u=Me(c.to,e,t,[...o,c],s-1),g=c.cost+u.cost;(!n||g<n.cost)&&(n={cost:g,edge:c,next:u})}return n??{cost:1/0}}r(Me,"findPath");function St(i){let e=[],t=i;for(;t?.edge;)e.push(t.edge),t=t.next;return e}r(St,"constructPipeline");function Ue(i,e){return St(Me(p(i),e))}r(Ue,"findPipeline");var We=require("stream");var b=I(require("prism-media"));var R=class{constructor(e,t,o,s){a(this,"playStream");a(this,"edges");a(this,"metadata");a(this,"volume");a(this,"encoder");a(this,"audioPlayer");a(this,"playbackDuration",0);a(this,"started",!1);a(this,"silencePaddingFrames");a(this,"silenceRemaining",-1);this.edges=e,this.playStream=t.length>1?(0,We.pipeline)(t,l):t[0],this.metadata=o,this.silencePaddingFrames=s;for(let n of t)n instanceof b.default.VolumeTransformer?this.volume=n:n instanceof b.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--,V;let e=this.playStream.read();return e&&(this.playbackDuration+=20),e}};r(R,"AudioResource");var Ct=r(i=>i.some(e=>e.type==="volume transformer"),"VOLUME_CONSTRAINT"),kt=r(()=>!0,"NO_CONSTRAINT");function At(i){return i instanceof b.default.opus.Encoder?{streamType:"opus",hasVolume:!1}:i instanceof b.default.opus.Decoder?{streamType:"raw",hasVolume:!1}:i instanceof b.default.VolumeTransformer?{streamType:"raw",hasVolume:!0}:i instanceof b.default.opus.OggDemuxer?{streamType:"opus",hasVolume:!1}:i instanceof b.default.opus.WebmDemuxer?{streamType:"opus",hasVolume:!1}:{streamType:"arbitrary",hasVolume:!1}}r(At,"inferStreamType");function Fe(i,e={}){let t=e.inputType,o=Boolean(e.inlineVolume);if(typeof i=="string")t="arbitrary";else if(typeof t=="undefined"){let c=At(i);t=c.streamType,o=o&&!c.hasVolume}let s=Ue(t,o?Ct:kt);if(s.length===0){if(typeof i=="string")throw new Error(`Invalid pipeline constructed for string resource '${i}'`);return new R([],[i],e.metadata??null,e.silencePaddingFrames??5)}let n=s.map(c=>c.transformer(i));return typeof i!="string"&&n.unshift(i),new R(s,n,e.metadata??null,e.silencePaddingFrames??5)}r(Fe,"createAudioResource");var F=require("path"),Ge=I(require("prism-media"));function He(i,e,t){if(t===0)return;let o=(0,F.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 He((0,F.resolve)(i,".."),e,t-1)}}r(He,"findPackageJSON");function vt(i){try{return(i==="@discordjs/voice"?je():He((0,F.dirname)(require.resolve(i)),i,3))?.version??"not found"}catch{return"not found"}}r(vt,"version");function wt(){let i=[],e=r(t=>i.push(`- ${t}: ${vt(t)}`),"addVersion");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(` | ||
`)}r(wt,"generateDependencyReport");function Je(i){let e=new AbortController,t=setTimeout(()=>e.abort(),i);return e.signal.addEventListener("abort",()=>clearTimeout(t)),[e,e.signal]}r(Je,"abortAfter");var Le=require("events");async function xt(i,e,t){if(i.state.status!==e){let[o,s]=typeof t=="number"?Je(t):[void 0,t];try{await(0,Le.once)(i,e,{signal:s})}finally{o?.abort()}}return i}r(xt,"entersState");var $e=require("stream"),se=I(require("prism-media"));function qe(i){let e=i.readUInt8(9),t=i.readUInt32LE(12);return e===2&&t===48e3}r(qe,"validateDiscordOpusHead");function Vt(i,e=1024,t=qe){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),c,u=r(f=>{i.off("data",q),i.off("close",O),i.off("end",O),i.pause(),c=f,i.readableEnded?o({stream:$e.Readable.from(n),type:f}):(n.length>0&&i.push(n),o({stream:i,type:f}))},"finish"),g=r(f=>Ke=>{t(Ke)&&u(f)},"foundHead"),C=new se.default.opus.WebmDemuxer;C.once("error",l),C.on("head",g("webm/opus"));let k=new se.default.opus.OggDemuxer;k.once("error",l),k.on("head",g("ogg/opus"));let O=r(()=>{c||u("arbitrary")},"onClose"),q=r(f=>{n=Buffer.concat([n,f]),C.write(f),k.write(f),n.length>=e&&(i.off("data",q),i.pause(),process.nextTick(O))},"onData");i.once("error",s),i.on("data",q),i.once("close",O),i.once("end",O)})}r(Vt,"demuxProbe");module.exports=ot(Dt);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 |
174
package.json
{ | ||
"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" | ||
} | ||
} | ||
"name": "@discordjs/voice", | ||
"version": "0.9.0-dev.1644537980.298b226", | ||
"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.17.0", | ||
"@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.2", | ||
"@typescript-eslint/parser": "^5.10.2", | ||
"eslint": "^8.8.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.2", | ||
"prettier": "^2.4.1", | ||
"tsup": "^5.11.13", | ||
"tweetnacl": "^1.0.3", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.5.5" | ||
}, | ||
"engines": { | ||
"node": ">=16.9.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "0.9.0-dev" | ||
} |
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
473428
20
1898
9