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 {
|
try {
|
||||||
const { buffer, type } = await this.ipc.command("image", { type: "run", obj: magickParams }, true).catch(e => {
|
const { buffer, type } = await this.ipc.serviceCommand("image", { type: "run", obj: magickParams }, true, 9000000);
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
if (type === "nogif" && this.constructor.requiresGIF) return "That isn't a GIF!";
|
if (type === "nogif" && this.constructor.requiresGIF) return "That isn't a GIF!";
|
||||||
return {
|
return {
|
||||||
file: Buffer.from(buffer.data),
|
file: Buffer.from(buffer.data),
|
||||||
name: `${this.constructor.command}.${type}`
|
name: `${this.constructor.command}.${type}`
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} 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.";
|
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;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -4,7 +4,7 @@ class ImageReloadCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
const owners = process.env.OWNER.split(",");
|
const owners = process.env.OWNER.split(",");
|
||||||
if (!owners.includes(this.message.author.id)) return "Only the bot owner can reload the image servers!";
|
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) {
|
if (amount > 0) {
|
||||||
return `Successfully connected to ${amount} image servers.`;
|
return `Successfully connected to ${amount} image servers.`;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
||||||
class ImageStatsCommand extends Command {
|
class ImageStatsCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
await this.client.sendChannelTyping(this.message.channel.id);
|
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 = {
|
const embed = {
|
||||||
embeds: [{
|
embeds: [{
|
||||||
"author": {
|
"author": {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class PrometheusWorker extends BaseServiceWorker {
|
||||||
# TYPE esmbot_shard_count gauge
|
# TYPE esmbot_shard_count gauge
|
||||||
`);
|
`);
|
||||||
if (process.env.API === "true") {
|
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
|
res.write(`# HELP esmbot_connected_workers Number of workers connected
|
||||||
# TYPE esmbot_connected_workers gauge
|
# TYPE esmbot_connected_workers gauge
|
||||||
esmbot_connected_workers ${servers.length}
|
esmbot_connected_workers ${servers.length}
|
||||||
|
|
Loading…
Reference in a new issue