mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Throw errors on missing voice dependencies
This commit is contained in:
@@ -233,15 +233,13 @@ var VoiceConnection = (function (_EventEmitter) {
|
|||||||
try {
|
try {
|
||||||
if (!self.encoder.opus) {
|
if (!self.encoder.opus) {
|
||||||
self.playing = false;
|
self.playing = false;
|
||||||
self.emit("error", "No Opus!");
|
throw new Error("node-opus not found! Perhaps you didn't install it.");
|
||||||
self.client.emit("debug", "Tried to use node-opus, but opus not available - install it!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self.encoder.sanityCheck()) {
|
if (!self.encoder.sanityCheck()) {
|
||||||
self.playing = false;
|
self.playing = false;
|
||||||
self.emit("error", "Opus sanity check failed!");
|
throw new Error("node-opus sanity check failed! Try re-installing node-opus.");
|
||||||
self.client.emit("debug", "Opus sanity check failed - opus is installed but not correctly! Please reinstall opus and make sure it's installed correctly.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
exports.__esModule = true;
|
exports.__esModule = true;
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
var _tweetnacl = require("tweetnacl");
|
var nacl;
|
||||||
|
try {
|
||||||
var _tweetnacl2 = _interopRequireDefault(_tweetnacl);
|
nacl = require("tweetnacl");
|
||||||
|
} catch (e) {
|
||||||
|
// no tweetnacl!
|
||||||
|
}
|
||||||
|
|
||||||
var nonce = new Buffer(24);
|
var nonce = new Buffer(24);
|
||||||
nonce.fill(0);
|
nonce.fill(0);
|
||||||
@@ -16,6 +17,9 @@ nonce.fill(0);
|
|||||||
var VoicePacket = function VoicePacket(data, sequence, time, ssrc, secret) {
|
var VoicePacket = function VoicePacket(data, sequence, time, ssrc, secret) {
|
||||||
_classCallCheck(this, VoicePacket);
|
_classCallCheck(this, VoicePacket);
|
||||||
|
|
||||||
|
if (!nacl) {
|
||||||
|
throw new Error("tweetnacl not found! Perhaps you didn't install it.");
|
||||||
|
}
|
||||||
var mac = secret ? 16 : 0;
|
var mac = secret ? 16 : 0;
|
||||||
var packetLength = data.length + 12 + mac;
|
var packetLength = data.length + 12 + mac;
|
||||||
|
|
||||||
@@ -33,7 +37,7 @@ var VoicePacket = function VoicePacket(data, sequence, time, ssrc, secret) {
|
|||||||
if (secret) {
|
if (secret) {
|
||||||
// copy first 12 bytes
|
// copy first 12 bytes
|
||||||
returnBuffer.copy(nonce, 0, 0, 12);
|
returnBuffer.copy(nonce, 0, 0, 12);
|
||||||
audioBuffer = _tweetnacl2["default"].secretbox(data, nonce, secret);
|
audioBuffer = nacl.secretbox(data, nonce, secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < audioBuffer.length; i++) {
|
for (var i = 0; i < audioBuffer.length; i++) {
|
||||||
|
|||||||
@@ -197,15 +197,13 @@ export default class VoiceConnection extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
if (!self.encoder.opus){
|
if (!self.encoder.opus){
|
||||||
self.playing=false;
|
self.playing=false;
|
||||||
self.emit("error", "No Opus!");
|
throw new Error("node-opus not found! Perhaps you didn't install it.");
|
||||||
self.client.emit("debug", "Tried to use node-opus, but opus not available - install it!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self.encoder.sanityCheck()) {
|
if (!self.encoder.sanityCheck()) {
|
||||||
self.playing = false;
|
self.playing = false;
|
||||||
self.emit("error", "Opus sanity check failed!");
|
throw new Error("node-opus sanity check failed! Try re-installing node-opus.");
|
||||||
self.client.emit("debug", "Opus sanity check failed - opus is installed but not correctly! Please reinstall opus and make sure it's installed correctly.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import nacl from "tweetnacl";
|
var nacl;
|
||||||
|
try {
|
||||||
|
nacl = require("tweetnacl");
|
||||||
|
} catch (e) {
|
||||||
|
// no tweetnacl!
|
||||||
|
}
|
||||||
|
|
||||||
const nonce = new Buffer(24);
|
const nonce = new Buffer(24);
|
||||||
nonce.fill(0);
|
nonce.fill(0);
|
||||||
|
|
||||||
export default class VoicePacket {
|
export default class VoicePacket {
|
||||||
constructor(data, sequence, time, ssrc, secret){
|
constructor(data, sequence, time, ssrc, secret){
|
||||||
|
if(!nacl) {
|
||||||
|
throw new Error("tweetnacl not found! Perhaps you didn't install it.");
|
||||||
|
}
|
||||||
var mac = secret ? 16 : 0;
|
var mac = secret ? 16 : 0;
|
||||||
var packetLength = data.length + 12 + mac;
|
var packetLength = data.length + 12 + mac;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user