fixed for build, added npm commands

This commit is contained in:
djkato 2022-01-29 19:53:09 +01:00
parent 7072e8ab53
commit 3e7eba4fbb
7 changed files with 1169 additions and 11 deletions

4
.gitignore vendored
View file

@ -2,4 +2,6 @@ node_modules
.vscode
null
temp.txt
C4DRichPresence.bat
C4DRichPresence.bat
build/DRCSettings.json
src/DRCSettings.json

Binary file not shown.

Binary file not shown.

Binary file not shown.

1142
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,15 @@
"name": "discord-rich-presence-for-cinema-4d",
"version": "1.0.1",
"description": "A simple node project to show your friends on discord what you're working on in Cinema 4D! Bit hacky but it works x)",
"main": "Rich Presence for C4D.js",
"bin": "./src/Rich Presence for C4D.js",
"main": "./src/Rich Presence for C4D.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node \"./src/Rich Presence for C4D.js\"",
"build": "pkg ."
},
"pkg": {
"output": "dist",
"outputPath": "./build"
},
"repository": {
"type": "git",
@ -27,6 +33,7 @@
},
"homepage": "https://github.com/djkato/Discord-Rich-Presence-For-Cinema-4D#readme",
"dependencies": {
"discord-rich-presence": "0.0.8"
"discord-rich-presence": "0.0.8",
"pkg": "^5.5.2"
}
}

View file

@ -10,7 +10,14 @@ let pastProject = "."
//Command used to scan for C4D process
let cmd = 'tasklist /fi "imagename eq Cinema 4D.exe" /fo list /v'
//Loads DRC settings
let DRCSettings = JSON.parse(fs.readFileSync("DRCSettings.json"))
let DRCSettings
try {
DRCSettings = JSON.parse(fs.readFileSync("DRCSettings.json"))
} catch (err) {
DRCSettings = { "portfolio_website": "djkato.net", "scan_refresh_rate": 1000 }
fs.writeFileSync("DRCSettings.json", JSON.stringify(DRCSettings))
}
let clientIsConnected = false
let currentClient
@ -38,11 +45,11 @@ function updateOpenProjectName(str) {
str = str[1].split("]")
if (str[0].includes("*")) {
str = str[0].substring(0, str[0].length - 2)
console.log(str)
//console.log(str)
currentProject = str.toString()
}
else {
console.log(str[0])
//console.log(str[0])
currentProject = str[0].toString()
}
}
@ -54,10 +61,10 @@ function setDRCProject() {
if (!clientIsConnected) {
currentClient = client("936296341250904065")
currentClient.on("error", (err) => {
console.log("err")
//console.log("err")
})
clientIsConnected = true
console.log("starting client")
//console.log("starting client")
currentProject = "0"
}
if (currentProject != pastProject) {
@ -68,7 +75,7 @@ function setDRCProject() {
largeImageKey: 'c4d',
instance: true,
})
console.log("updating client")
//console.log("updating client")
}
pastProject = currentProject
@ -83,7 +90,7 @@ async function main() {
if (clientIsConnected) {
await currentClient.disconnect()
clientIsConnected = false
console.log("disconnecting client...")
//console.log("disconnecting client...")
}
await sleep(DRCSettings.scan_refresh_rate * 10)
continue