mrmBot-Matrix/commands/general/imagereload.js

34 lines
1,002 B
JavaScript
Raw Normal View History

2023-03-15 14:09:09 +00:00
import Command from "../../classes/command.js";
import { reloadImageConnections } from "../../utils/image.js";
class ImageReloadCommand extends Command {
2023-03-19 05:10:48 +00:00
static category = "general"
2023-03-15 14:09:09 +00:00
async run() {
const owners = process.env.OWNER.split(",");
2023-03-15 14:12:35 +00:00
if (!owners.includes(this.author)) {
2023-03-15 14:09:09 +00:00
this.success = false;
return "Only the bot owner can reload the image servers!";
}
2023-03-17 00:23:01 +00:00
// await this.acknowledge();
2023-03-15 14:09:09 +00:00
const length = await reloadImageConnections();
if (!length) {
if (process.env.PM2_USAGE) {
process.send({
type: "process:msg",
data: {
type: "imagereload"
}
});
}
return `Successfully connected to ${length} image server(s).`;
} else {
return "I couldn't connect to any image servers!";
}
}
static description = "Attempts to reconnect to all available image processing servers";
static adminOnly = true;
}
export default ImageReloadCommand;