diff --git a/assets/images/region-flags b/assets/images/region-flags index b26219b..e2887e4 160000 --- a/assets/images/region-flags +++ b/assets/images/region-flags @@ -1 +1 @@ -Subproject commit b26219baeb920506e40bc6db42fcde609fb499c7 +Subproject commit e2887e42da18273f2c2eaac1ae5a973111434c90 diff --git a/commands/general/soundreload.js b/commands/general/soundreload.js index 7e924d0..8d6a766 100644 --- a/commands/general/soundreload.js +++ b/commands/general/soundreload.js @@ -1,16 +1,23 @@ -const soundPlayer = require("../../utils/soundplayer.js"); const Command = require("../../classes/command.js"); class SoundReloadCommand extends Command { - async run() { - if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload Lavalink!"; - const soundStatus = await soundPlayer.checkStatus(); - if (!soundStatus) { - const length = await soundPlayer.connect(this.client); - return `Successfully connected to ${length} Lavalink node(s).`; - } else { - return "I couldn't connect to any Lavalink nodes!"; - } + // another very hacky command + run() { + return new Promise((resolve) => { + if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload Lavalink!"; + this.message.channel.sendTyping(); + this.ipc.broadcast("soundreload"); + this.ipc.register("soundReloadSuccess", (msg) => { + this.ipc.unregister("soundReloadSuccess"); + this.ipc.unregister("soundReloadFail"); + resolve(`Successfully connected to ${msg.length} Lavalink node(s).`); + }); + this.ipc.register("soundReloadFail", () => { + this.ipc.unregister("soundReloadSuccess"); + this.ipc.unregister("soundReloadFail"); + resolve("I couldn't connect to any Lavalink nodes!"); + }); + }); } static description = "Attempts to reconnect to all available Lavalink nodes"; diff --git a/shard.js b/shard.js index d3f2f52..c9ec3f0 100644 --- a/shard.js +++ b/shard.js @@ -152,6 +152,16 @@ connected_workers ${image.connections.length} if (result2) return this.ipc.broadcast("reloadFail", { result: result2 }); return this.ipc.broadcast("reloadSuccess"); }); + + this.ipc.register("soundreload", async () => { + const soundStatus = await sound.checkStatus(); + if (!soundStatus) { + const length = await sound.connect(this.bot); + return this.ipc.broadcast("soundReloadSuccess", { length }); + } else { + return this.ipc.broadcast("soundReloadFail"); + } + }); // connect to lavalink if (!sound.status && !sound.connected) await sound.connect(this.bot); diff --git a/utils/image.js b/utils/image.js index 409b6da..7d7e16e 100644 --- a/utils/image.js +++ b/utils/image.js @@ -85,7 +85,7 @@ exports.connect = (server) => { this.jobs[req].event.emit("uuid", uuid); } } else if (opcode === 0x01) { // Job completed successfully - // the image API sends all job responses over the same socket; make sure this is ours + // the image API sends all job responses over the same socket; make sure this is ours if (this.jobs[uuid]) { const imageReq = await fetch(`http://${connection.remoteAddress}:8081/image?id=${uuid}`); const image = await imageReq.buffer(); @@ -232,9 +232,11 @@ exports.getType = async (image) => { controller.abort(); }, 25000); try { - const imageRequest = await fetch(image, { signal: controller.signal, headers: { - "Range": "bytes=0-1023" - }}); + const imageRequest = await fetch(image, { + signal: controller.signal, headers: { + "Range": "bytes=0-1023" + } + }); clearTimeout(timeout); const size = imageRequest.headers.has("Content-Range") ? imageRequest.headers.get("Content-Range").split("/")[1] : imageRequest.headers.get("Content-Length"); if (parseInt(size) > 20971520) { @@ -277,7 +279,7 @@ exports.run = object => { data.event.once("image", (image, type) => { delete this.jobs[data.uuid]; const payload = { - // Take just the image data + // Take just the image data buffer: image, type: type };