mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Made opus truly optional
This commit is contained in:
@@ -14,9 +14,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
||||
var WebSocket = require("ws");
|
||||
var dns = require("dns");
|
||||
var udp = require("dgram");
|
||||
var Opus = require('node-opus');
|
||||
var fs = require("fs");
|
||||
var ffmpeg = require('fluent-ffmpeg');
|
||||
var AudioEncoder = require("./AudioEncoder.js");
|
||||
var VoicePacket = require("./VoicePacket.js");
|
||||
var StreamIntent = require("./StreamIntent.js");
|
||||
@@ -29,9 +27,6 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
_classCallCheck(this, VoiceConnection);
|
||||
|
||||
_EventEmitter.call(this);
|
||||
if (!Opus) {
|
||||
console.log("HEY! WATCH OUT\n\n discord.js needs node-opus, you don't have it installed.");
|
||||
}
|
||||
this.id = channel.id;
|
||||
this.voiceChannel = channel;
|
||||
this.client = client;
|
||||
@@ -42,7 +37,6 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
this.vWS = null; // vWS means voice websocket
|
||||
this.ready = false;
|
||||
this.vWSData = {};
|
||||
this.opus = new Opus.OpusEncoder(48000, 1);
|
||||
this.encoder = new AudioEncoder();
|
||||
this.udp = null;
|
||||
this.playingIntent = null;
|
||||
@@ -165,7 +159,12 @@ var VoiceConnection = (function (_EventEmitter) {
|
||||
var self = this;
|
||||
self.playing = true;
|
||||
try {
|
||||
|
||||
if (!self.encoder.opus) {
|
||||
self.playing = false;
|
||||
self.emit("error", "No Opus!");
|
||||
self.emit("debug", "Tried to use node-opus, but opus not available - install it!");
|
||||
return;
|
||||
}
|
||||
var buffer = self.encoder.opusBuffer(rawbuffer);
|
||||
var packet = new VoicePacket(buffer, sequence, timestamp, self.vWSData.ssrc);
|
||||
return self.sendPacket(packet, callback);
|
||||
|
||||
Reference in New Issue
Block a user