Replace deprecated image service functions
This commit is contained in:
parent
6475c91fbc
commit
25e2ac088f
4 changed files with 6 additions and 8 deletions
|
@ -100,16 +100,14 @@ class ImageCommand extends Command {
|
|||
}
|
||||
|
||||
try {
|
||||
const { buffer, type } = await this.ipc.command("image", { type: "run", obj: magickParams }, true).catch(e => {
|
||||
throw e;
|
||||
});
|
||||
const { buffer, type } = await this.ipc.serviceCommand("image", { type: "run", obj: magickParams }, true, 9000000);
|
||||
if (type === "nogif" && this.constructor.requiresGIF) return "That isn't a GIF!";
|
||||
return {
|
||||
file: Buffer.from(buffer.data),
|
||||
name: `${this.constructor.command}.${type}`
|
||||
};
|
||||
} catch (e) {
|
||||
if (e === "Job timed out") return "The image is taking too long to process (>=15 minutes), so the job was cancelled. Try using a smaller image.";
|
||||
if (e === "Job timed out" || e === "Timeout") return "The image is taking too long to process (>=15 minutes), so the job was cancelled. Try using a smaller image.";
|
||||
if (e.toString().includes("Not connected to image server") || e === "No available servers") return "I can't seem to contact the image servers, they might be down or still trying to start up. Please wait a little bit.";
|
||||
throw e;
|
||||
} finally {
|
||||
|
|
|
@ -4,7 +4,7 @@ class ImageReloadCommand extends Command {
|
|||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.message.author.id)) return "Only the bot owner can reload the image servers!";
|
||||
const amount = await this.ipc.command("image", { type: "reload" }, true);
|
||||
const amount = await this.ipc.serviceCommand("image", { type: "reload" }, true);
|
||||
if (amount > 0) {
|
||||
return `Successfully connected to ${amount} image servers.`;
|
||||
} else {
|
||||
|
@ -16,4 +16,4 @@ class ImageReloadCommand extends Command {
|
|||
static aliases = ["magickconnect", "magick"];
|
||||
}
|
||||
|
||||
export default ImageReloadCommand;
|
||||
export default ImageReloadCommand;
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
class ImageStatsCommand extends Command {
|
||||
async run() {
|
||||
await this.client.sendChannelTyping(this.message.channel.id);
|
||||
const servers = await this.ipc.command("image", { type: "stats" }, true);
|
||||
const servers = await this.ipc.serviceCommand("image", { type: "stats" }, true);
|
||||
const embed = {
|
||||
embeds: [{
|
||||
"author": {
|
||||
|
|
|
@ -21,7 +21,7 @@ class PrometheusWorker extends BaseServiceWorker {
|
|||
# TYPE esmbot_shard_count gauge
|
||||
`);
|
||||
if (process.env.API === "true") {
|
||||
const servers = await this.ipc.command("image", { type: "stats" }, true);
|
||||
const servers = await this.ipc.serviceCommand("image", { type: "stats" }, true);
|
||||
res.write(`# HELP esmbot_connected_workers Number of workers connected
|
||||
# TYPE esmbot_connected_workers gauge
|
||||
esmbot_connected_workers ${servers.length}
|
||||
|
|
Loading…
Reference in a new issue