diff --git a/api/index.js b/api/index.js index 956ad48..ca2d0c0 100644 --- a/api/index.js +++ b/api/index.js @@ -37,10 +37,24 @@ if (isMainThread) { delete jobs[uuid]; } }); - worker.on("error", err => console.error("worker error:", err)); + worker.on("error", err => { + console.error("worker error:", err); + socket.send(Buffer.concat([Buffer.from([0x2]), Buffer.from(err.toString())]), jobs[uuid].port, jobs[uuid].addr); + + workingWorkers--; + if (queue.length > 0) { + acceptJob(queue[0]); + delete jobs[uuid]; + } + }); worker.on("exit", (code) => { - if (code !== 0) - console.error(`Worker stopped with exit code ${code}`); + workingWorkers--; + if (queue.length > 0) { + acceptJob(queue[0]); + delete jobs[uuid]; + } + + if (code !== 0) console.error(`Worker stopped with exit code ${code}`); }); diff --git a/binding.gyp b/binding.gyp index 6fc0867..28b0225 100644 --- a/binding.gyp +++ b/binding.gyp @@ -12,7 +12,7 @@ "libraries": [ " { const image = await require("../utils/imagedetect.js")(message); if (image === undefined) return `${message.author.mention}, you need to provide an image to sharpen!`; const { buffer, type } = await magick.run({ - cmd: "sharpen", + cmd: "blur", path: image.path, sharp: true }); diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 6db9c45..e860e31 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -58,7 +58,7 @@ exports.play = async (sound, message, music = false) => { const oldQueue = this.queues.get(voiceChannel.guild.id); if (tracks.length === 0) return `${message.author.mention}, I couldn't find that song!`; if (music) { - this.queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]); + this.queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]); } let connection; if (player) {