feat: RestartCommand
This commit is contained in:
@@ -1 +1 @@
|
||||
1262
|
||||
1267
|
||||
@@ -104,7 +104,7 @@ public class Main {
|
||||
|
||||
// no need to reset backupFailTimes because we are stopping anyway
|
||||
|
||||
stop();
|
||||
stop(0);
|
||||
}
|
||||
}, 0, config.backup.interval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class Main {
|
||||
}
|
||||
|
||||
// most of these are stolen from HBot
|
||||
public static void stop () {
|
||||
public static void stop (int exitCode) {
|
||||
if (stopping) return;
|
||||
|
||||
stopping = true;
|
||||
@@ -199,6 +199,6 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
System.exit(exitCode);
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,9 @@ public class EndCommand extends Command {
|
||||
public EndCommand () {
|
||||
super(
|
||||
"end",
|
||||
"End/Reconnects the bot",
|
||||
"Reconnects the bot",
|
||||
new String[] { "" },
|
||||
new String[] { "reconnect", "restart" },
|
||||
new String[] { "reconnect" },
|
||||
TrustLevel.TRUSTED,
|
||||
false
|
||||
);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.chayapak1.chomens_bot.commands;
|
||||
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
import me.chayapak1.chomens_bot.Main;
|
||||
import me.chayapak1.chomens_bot.command.Command;
|
||||
import me.chayapak1.chomens_bot.command.CommandContext;
|
||||
import me.chayapak1.chomens_bot.command.CommandException;
|
||||
import me.chayapak1.chomens_bot.command.TrustLevel;
|
||||
import me.chayapak1.chomens_bot.util.ColorUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class RestartCommand extends Command {
|
||||
public RestartCommand() {
|
||||
super(
|
||||
"restart",
|
||||
"Gracefully restarts the bot",
|
||||
new String[] { "" },
|
||||
new String[] {},
|
||||
TrustLevel.OWNER,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute(CommandContext context) throws CommandException {
|
||||
context.checkOverloadArgs(0);
|
||||
|
||||
final Bot bot = context.bot;
|
||||
|
||||
Main.stop(1);
|
||||
|
||||
return Component.text("Restarting").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class StopCommand extends Command {
|
||||
|
||||
final Bot bot = context.bot;
|
||||
|
||||
Main.stop();
|
||||
Main.stop(0);
|
||||
|
||||
return Component.text("Stopping").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class CommandHandlerPlugin {
|
||||
registerCommand(new StopCommand());
|
||||
registerCommand(new GrepLogCommand());
|
||||
registerCommand(new FindAltsCommand());
|
||||
registerCommand(new RestartCommand());
|
||||
}
|
||||
|
||||
public boolean disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user