Add restart command

This commit is contained in:
Zerebos 2025-01-26 04:05:15 -05:00
parent ced53a8732
commit 6c39f41077
No known key found for this signature in database
4 changed files with 28 additions and 5 deletions

View File

@ -38,9 +38,9 @@ const openPath = (event, path) => {
else shell.openPath(path);
};
const relaunch = () => {
const relaunch = (event, args = []) => {
app.relaunch({args: process.argv.slice(1).concat(Array.isArray(args) ? args : [args])});
app.quit();
app.relaunch();
};
const runScript = async (event, script) => {

View File

@ -1,6 +1,7 @@
import Builtin from "@structs/builtin";
import buildAddonCommand from "./addons";
import DebugCommand from "./debug";
import RestartCommand from "./restart";
export default new class DefaultCommands extends Builtin {
@ -12,7 +13,8 @@ export default new class DefaultCommands extends Builtin {
this.addCommands(
buildAddonCommand("plugin"),
buildAddonCommand("theme"),
DebugCommand
DebugCommand,
RestartCommand
);
}

View File

@ -0,0 +1,21 @@
import {OptionTypes} from "@modules/commandmanager";
import ipc from "@modules/ipc";
export default {
id: "restart",
name: "restart",
description: "Restart Discord with or without BetterDiscord",
options: [
{
type: OptionTypes.BOOLEAN,
name: "vanilla",
description: "Should Discord be relaunched without BetterDiscord?",
required: true,
},
],
execute: async (data) => {
const vanilla = data.find(o => o.name === "vanilla").value;
ipc.relaunch(vanilla ? ["--vanilla"] : []);
}
};

View File

@ -25,8 +25,8 @@ export default new class IPCRenderer {
return ipc.send(IPCEvents.TOGGLE_DEVTOOLS);
}
relaunch() {
return ipc.send(IPCEvents.RELAUNCH);
relaunch(args) {
return ipc.send(IPCEvents.RELAUNCH, args);
}
runScript(script) {