Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
fix toolkit not getting extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
RatWasHere committed Aug 19, 2023
1 parent bb063f3 commit 776ad30
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 152 deletions.
Binary file modified AppData.zip
Binary file not shown.
78 changes: 78 additions & 0 deletions AppData/Kits/Toolkit/botInit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const runCmd = require("node-run-cmd");
const customFs = require("fs");

const filePath = "./bot.js";
function consoleLog(log) {
document.getElementById(
"console",
).innerHTML += `<div class="fade" style="margin: auto; margin-top: 6px;">${ansiToHtml(
log,
)}</div>`;
}

let ranbot = false;

const fs = require("fs");
const { exec } = require("child_process");
const os = require("os");

exec("node -v", (error, stdout, stderr) => {
if (error) {
consoleLog(
"Node.js is not installed. Downloading now... (This will take a while..)",
);
const platform = os.platform();

if (platform === "win32") {
exec(
"winget install --accept-source-agreements --accept-package-agreements nodeJS",
(error, stdout, stderr) => {
if (error) {
consoleLog(
`Error occured whilst downloading Node.JS, please visit the support guild or download Node.JS manually`,
);
return;
}
consoleLog(
`Finished downloading Node.js! Studio Bot Maker will close in order to comply with the new changes. Please reopen it afterwards!`,
);

setTimeout(() => {
require("electron").ipcRenderer.send("restart", true);
}, 7500);
},
);
} else {
consoleLog(
"winget is only available on Windows. Please download it manually",
);
}
} else {
consoleLog(`Node.JS ${stdout} is already installed, jumping directly to Startup.`);
consoleLog(`Checking NPM modules.. This might take a bit`);

exec("npm i [email protected]", (err) => {
runBot()
});
exec("npm i @oceanicjs/builders");
exec("npm i discord-api-types");
}
});

async function runBot() {
if (ranbot == true) return;
ranbot = true;
customFs.writeFileSync(
"bot.js",
customFs.readFileSync("./AppData/bot.js", "utf8"),
);
runCmd
.run(`node ${filePath}`, { onData: consoleLog, onError: consoleLog, oncancel: cancelWindow })
.catch((error) => {
consoleLog(`Error executing bot.js: ${error}`);
});
}

let cancelWindow = () => {
ipcRenderer.send('')
}
22 changes: 22 additions & 0 deletions AppData/Kits/Toolkit/interactionTools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
stopExecution(uID) {
var tempVars = JSON.parse(fs.readFileSync("./tempVars.json", "utf8"));

tempVars[uID][`${uID}_stop`] = true;
fs.writeFileSync("./tempVars.json", JSON.stringify(tempVars));
},
async runCommand(id, actionRunner, uID, client, message) {
const datjson = require("../data.json");
for (let command in datjson.commands) {
if (datjson.commands[command].customId == id) {
await actionRunner(command, message, client, uID);
}
}
},
preventDeletion(uID) {
return;
},
leak(uID, customTimestamp) {
return;
},
};
7 changes: 7 additions & 0 deletions AppData/Kits/Toolkit/storedData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"users": { "702073622059155466": { "uy": "undefined796790351083339816" } },
"guilds": {},
"members": {},
"channels": {},
"lists": {}
}
31 changes: 31 additions & 0 deletions AppData/Kits/Toolkit/variableTools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
transf(text, variables) {
try {
const tempVars = (variable) => {
if (typeof variables[variable] == 'string' || variables[variable] == undefined || typeof variables[variable] == 'number') {
return variables[variable];
} else {
try {
if (variables[variable].userID) {
return `<@${variables[variable].user.id}>`
} else if (variables[variable].topic && variables[variable].guildID) {
return `<#${variables[variable].id}>`
} else if (variables[variable].publicFlags) {
return `<@${variables[variable].id}>`
} else if (typeof variables[variable].hoist == "boolean") {
return `<@&${variables[variable].id}>`
}
} catch (err) {return variables[variable]}
}
};

let formattedText = text;
if (formattedText.includes("`")) {
formattedText = formattedText.replace(/`/g, "\\`");
}

const evaluatedText = eval("`" + formattedText + "`");
return evaluatedText;
} catch (err) {return ''}
},
};
115 changes: 0 additions & 115 deletions AppData/Project/data.json

This file was deleted.

12 changes: 7 additions & 5 deletions AppData/Toolkit/botInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const fs = require("fs");
const { exec } = require("child_process");
const os = require("os");

exec("node -v", async (error, stdout, stderr) => {
exec("node -v", (error, stdout, stderr) => {
if (error) {
consoleLog(
"Node.js is not installed. Downloading now... (This will take a while..)",
Expand Down Expand Up @@ -48,12 +48,14 @@ exec("node -v", async (error, stdout, stderr) => {
);
}
} else {
consoleLog(`Node.JS is already installed, jumping directly to Startup.`);
consoleLog(`Node.JS ${stdout} is already installed, jumping directly to Startup.`);
consoleLog(`Checking NPM modules.. This might take a bit`);

exec("npm i [email protected]");

runBot();
exec("npm i [email protected]", (err) => {
runBot()
});
exec("npm i @oceanicjs/builders");
exec("npm i discord-api-types");
}
});

Expand Down
1 change: 0 additions & 1 deletion AppData/Toolkit/tempStoreact.txt

This file was deleted.

Empty file removed AppData/Toolkit/tempStoreobj.txt
Empty file.
1 change: 0 additions & 1 deletion AppData/Toolkit/tempVars.json

This file was deleted.

16 changes: 0 additions & 16 deletions AppData/Toolkit/variableTools.txt

This file was deleted.

7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ app.on("ready", () => {
async function main() {
try {
await downloadFile(
"https://cdn.glitch.global/a683cb76-598f-4483-808e-6a7d6eee6c26/AppData.zip?v=1692375136436",
"https://cdn.glitch.global/a683cb76-598f-4483-808e-6a7d6eee6c26/AppData.zip?v=1692416472881",
"AppData.zip",
);
if (!fs.existsSync("AppData")) {
Expand All @@ -171,6 +171,11 @@ app.on("ready", () => {
.find((dir) => dir.toLowerCase() === "appdata");
const appdPath = fs.realpathSync(path.join(tempDir, appdDir));
fse.copySync(appdPath, "AppData");
try {
fs.mkdir('./AppData/Toolkit')
} catch (error) {}
fse.copySync('./AppData/Kits/Toolkit', "./AppData/Toolkit");

fse.removeSync(appdPath);
fs.rmdirSync(tempDir, { recursive: true });
try {
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 776ad30

Please sign in to comment.