mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 08:41:29 +00:00
fix: decode voice ws data as json
This commit is contained in:
parent
b5aff6d120
commit
8652e47c14
2 changed files with 3 additions and 3 deletions
|
|
@ -26,8 +26,8 @@ exports.encoding = erlpack ? 'etf' : 'json';
|
||||||
|
|
||||||
exports.pack = erlpack ? erlpack.pack : JSON.stringify;
|
exports.pack = erlpack ? erlpack.pack : JSON.stringify;
|
||||||
|
|
||||||
exports.unpack = data => {
|
exports.unpack = (data, type) => {
|
||||||
if (exports.encoding === 'json') {
|
if (exports.encoding === 'json' || type === 'json') {
|
||||||
if (typeof data !== 'string') {
|
if (typeof data !== 'string') {
|
||||||
data = ab.decode(data);
|
data = ab.decode(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ class VoiceWebSocket extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
onMessage(event) {
|
onMessage(event) {
|
||||||
try {
|
try {
|
||||||
return this.onPacket(WebSocket.unpack(event.data));
|
return this.onPacket(WebSocket.unpack(event.data, 'json'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return this.onError(error);
|
return this.onError(error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue