mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
For some reason there's a way to join text channels via the Discord API but not the Discord Client, so this commit prevents the Client from crashing by checking to see if the channels are voice channels.
30 lines
774 B
JavaScript
30 lines
774 B
JavaScript
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var VoicePacket = function VoicePacket(data, sequence, time, ssrc) {
|
|
_classCallCheck(this, VoicePacket);
|
|
|
|
var audioBuffer = data,
|
|
returnBuffer = new Buffer(audioBuffer.length + 12);
|
|
|
|
returnBuffer.fill(0);
|
|
returnBuffer[0] = 0x80;
|
|
returnBuffer[1] = 0x78;
|
|
|
|
returnBuffer.writeUIntBE(sequence, 2, 2);
|
|
returnBuffer.writeUIntBE(time, 4, 4);
|
|
returnBuffer.writeUIntBE(ssrc, 8, 4);
|
|
|
|
for (var i = 0; i < audioBuffer.length; i++) {
|
|
returnBuffer[i + 12] = audioBuffer[i];
|
|
}
|
|
|
|
return returnBuffer;
|
|
};
|
|
|
|
exports["default"] = VoicePacket;
|
|
module.exports = exports["default"];
|