Skip to content

Commit

Permalink
reload support multiple separate subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
Supinic committed Nov 26, 2024
1 parent 6eeba5c commit 030f35c
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions commands/restart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const methods = {
commands: ["yarn build"]
}
};
const methodNames = ["all", ...Object.keys(methods)];

module.exports = {
Name: "restart",
Expand All @@ -39,24 +38,16 @@ module.exports = {
Flags: ["system", "whitelist"],
Params: null,
Whitelist_Response: "Only available to administrators or helpers!",
Code: async function restart (context, reloadCommand) {
if (reloadCommand && !methodNames.includes(reloadCommand)) {
return {
success: false,
reply: `Invalid command provided! Use one of: ${methodNames.join(", ")}`
};
}

const commandsToRun = [];
if (reloadCommand === "all") {
commandsToRun.push(...Object.keys(methods));
}
else if (reloadCommand) {
commandsToRun.push(reloadCommand);
}

Code: async function restart (context, ...commands) {

Check warning on line 41 in commands/restart/index.js

View workflow job for this annotation

GitHub Actions / test

'commands' is defined but never used
for (const name of commandsToRun) {

Check failure on line 42 in commands/restart/index.js

View workflow job for this annotation

GitHub Actions / test

'commandsToRun' is not defined
const reloadCommand = methods[name];
if (!reloadCommand) {
return {
success: false,
reply: `Incorrect reload command provided! Use one of: ${Object.keys(methods).join(", ")}`
};
}

await context.sendIntermediateMessage(`VisLaud 👉 ${reloadCommand.message}`);

for (const command of reloadCommand.commands) {
Expand Down

0 comments on commit 030f35c

Please sign in to comment.