mrmBot-Matrix/commands/general/imagestats.js

31 lines
1 KiB
JavaScript
Raw Normal View History

import Command from "../../classes/command.js";
class ImageStatsCommand extends Command {
async run() {
2021-08-14 02:34:44 +00:00
await this.client.sendChannelTyping(this.message.channel.id);
const servers = await this.ipc.command("image", { type: "stats" }, true);
const embed = {
2021-11-10 04:09:10 +00:00
embeds: [{
"author": {
"name": "esmBot Image Statistics",
"icon_url": this.client.user.avatarURL
},
"color": 16711680,
"description": `The bot is currently connected to ${servers.length} image server(s).`,
"fields": []
2021-11-10 04:09:10 +00:00
}]
};
for (let i = 0; i < servers.length; i++) {
2021-11-10 04:09:10 +00:00
embed.embeds[0].fields.push({
name: `Server ${i + 1}`,
2021-11-27 05:24:13 +00:00
value: `Running Jobs: ${servers[i].runningJobs}\nQueued: ${Math.max(0, servers[i].runningJobs - servers[i].max)}\nMax Jobs: ${servers[i].max}`
});
}
return embed;
}
static description = "Gets some statistics about the image servers";
static aliases = ["imgstat", "imstats", "imgstats", "imstat"];
}
export default ImageStatsCommand;