mrmBot-Matrix/commands/general/soundreload.js

33 lines
982 B
JavaScript
Raw Normal View History

2023-03-15 14:09:09 +00:00
import Command from "../../classes/command.js";
import { reload } from "../../utils/soundplayer.js";
class SoundReloadCommand extends Command {
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 Lavalink!";
}
2023-03-17 00:23:01 +00:00
// await this.acknowledge();
2023-03-15 14:09:09 +00:00
const length = await reload();
if (process.env.PM2_USAGE) {
process.send({
type: "process:msg",
data: {
type: "soundreload"
}
});
}
if (length) {
return `Successfully connected to ${length} Lavalink node(s).`;
} else {
return "I couldn't connect to any Lavalink nodes!";
}
}
static description = "Attempts to reconnect to all available Lavalink nodes";
static aliases = ["lava", "lavalink", "lavaconnect", "soundconnect"];
static adminOnly = true;
}
export default SoundReloadCommand;