Fixed permission error & preparing for win build

This commit is contained in:
DJj123dj
2024-08-22 21:22:19 +02:00
parent 5e2e0417dc
commit 177ab95dba
5 changed files with 20 additions and 12 deletions
+9 -5
View File
@@ -3,9 +3,13 @@
const fs = require("fs") const fs = require("fs")
const child = require("child_process") const child = require("child_process")
if (!fs.existsSync("./dist/src/index.js")){
console.log("Compiling the bot...") console.log("Removing prebuilds...")
child.execSync("npm run build") fs.rmSync("./dist",{recursive:true,force:true})
console.log("\n\nFinished compilation!")
} console.log("Compiling the bot...")
//exit when only compilation is required
if (process.argv.includes("-%-compile")) process.exit(0)
//start the bot
require("./dist/src/index") require("./dist/src/index")
+2 -2
View File
@@ -12,8 +12,8 @@
], ],
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "rm -rf ./dist/ && npx tsc -p ./tsconfig.json", "build": "node index.js -%-compile && npx tsc -p ./tsconfig.json",
"start": "npm run build && node index.js", "start": "npm run build && node ./dist/src/index.js",
"test": "npm run start -- --dev-config --dev-database" "test": "npm run start -- --dev-config --dev-database"
}, },
"type": "commonjs", "type": "commonjs",
+3 -2
View File
@@ -90,8 +90,9 @@ export class ODJsonConfig extends ODConfig {
const filename = (file.endsWith(".json")) ? file : file+".json" const filename = (file.endsWith(".json")) ? file : file+".json"
this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./config/",filename) this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./config/",filename)
this.data = JSON.parse(fs.readFileSync(this.file).toString()) this.data = JSON.parse(fs.readFileSync(this.file).toString())
}catch{ }catch(err){
throw new ODSystemError("config \""+nodepath.join("./",customPath ?? "",file)+"\" doesn't exist!") process.emit("uncaughtException",err)
throw new ODSystemError("Config \""+nodepath.join("./",customPath ?? "./config/",file)+"\" doesn't exist!")
} }
} }
} }
+3 -2
View File
@@ -22,8 +22,9 @@ export class ODLanguage extends ODManagerData {
const filename = (file.endsWith(".json")) ? file : file+".json" const filename = (file.endsWith(".json")) ? file : file+".json"
this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./languages/",filename) this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./languages/",filename)
this.data = JSON.parse(fs.readFileSync(this.file).toString()) this.data = JSON.parse(fs.readFileSync(this.file).toString())
}catch{ }catch(err){
throw new ODSystemError("[API ERROR] Language \""+file+"\" doesn't exist!") process.emit("uncaughtException",err)
throw new ODSystemError("Language \""+nodepath.join("./",customPath ?? "./languages/",file)+"\" doesn't exist!")
} }
if (this.data["_TRANSLATION"]) this.metadata = this.data["_TRANSLATION"] if (this.data["_TRANSLATION"]) this.metadata = this.data["_TRANSLATION"]
} }
+3 -1
View File
@@ -63,6 +63,7 @@ export const addTicketPermissions = async (ticket:api.ODTicket) => {
const readAdmins = ticket.option.exists("openticket:admins-readonly") ? ticket.option.get("openticket:admins-readonly").value : [] const readAdmins = ticket.option.exists("openticket:admins-readonly") ? ticket.option.get("openticket:admins-readonly").value : []
admins.concat(readAdmins).forEach(async (admin) => { admins.concat(readAdmins).forEach(async (admin) => {
if (openticket.permissions.exists("openticket:ticket-admin_"+ticket.id.value+"_"+admin)) return
const role = await mainServer.roles.fetch(admin) const role = await mainServer.roles.fetch(admin)
if (!role) return openticket.log("Unable to register permission for ticket admin!","error",[ if (!role) return openticket.log("Unable to register permission for ticket admin!","error",[
{key:"roleid",value:admin} {key:"roleid",value:admin}
@@ -76,7 +77,8 @@ export const removeTicketPermissions = async (ticket:api.ODTicket) => {
const admins = ticket.option.exists("openticket:admins") ? ticket.option.get("openticket:admins").value : [] const admins = ticket.option.exists("openticket:admins") ? ticket.option.get("openticket:admins").value : []
const readAdmins = ticket.option.exists("openticket:admins-readonly") ? ticket.option.get("openticket:admins-readonly").value : [] const readAdmins = ticket.option.exists("openticket:admins-readonly") ? ticket.option.get("openticket:admins-readonly").value : []
admins.concat(readAdmins).forEach(async (admin) => { admins.concat(readAdmins).forEach(async (admin) => {
if (!openticket.permissions.exists("openticket:ticket-admin_"+ticket.id.value+"_"+admin)) return
openticket.permissions.remove("openticket:ticket-admin_"+ticket.id.value+"_"+admin) openticket.permissions.remove("openticket:ticket-admin_"+ticket.id.value+"_"+admin)
}) })
} }