Attempt at repairing crash and failing to stop RPC
This commit is contained in:
parent
49c20fd1f4
commit
fd5fd330b5
6 changed files with 32 additions and 5 deletions
12
!ERROR.txt
Normal file
12
!ERROR.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
(node:25384) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [RP]. Use emitter.setMaxListeners() to increase limit
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
C:\Users\djkato\Documents\Discord Rich Presence for Cinema 4D\src\Rich Presence for C4D.js:46
|
||||
str = str[1].split("]")
|
||||
^
|
||||
|
||||
TypeError: Cannot read properties of undefined (reading 'split')
|
||||
at updateOpenProjectName (C:\Users\djkato\Documents\Discord Rich Presence for Cinema 4D\src\Rich Presence for C4D.js:46:22)
|
||||
at main (C:\Users\djkato\Documents\Discord Rich Presence for Cinema 4D\src\Rich Presence for C4D.js:98:9)
|
||||
at runMicrotasks (<anonymous>)
|
||||
at processTicksAndRejections (node:internal/process/task_queues:96:5)
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ temp.txt
|
|||
C4DRichPresence.bat
|
||||
build/DRCSettings.json
|
||||
src/DRCSettings.json
|
||||
!ERROR.txt
|
1
DRCSettings.json
Normal file
1
DRCSettings.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"portfolio_website":"djkato.net","scan_refresh_rate":1000}
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "discord-rich-presence-for-cinema-4d",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"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)",
|
||||
"bin": "./src/Rich Presence for C4D.js",
|
||||
"main": "./src/Rich Presence for C4D.js",
|
||||
|
|
|
@ -35,6 +35,7 @@ function getCinemaProcessInfo() {
|
|||
}
|
||||
|
||||
function updateOpenProjectName(str) {
|
||||
//if project file found sets current project to name, else currentProject = false
|
||||
if (str.includes("No tasks")) {
|
||||
currentProject = false
|
||||
return
|
||||
|
@ -42,6 +43,8 @@ function updateOpenProjectName(str) {
|
|||
str = str.split("Window Title:")
|
||||
if (str[1].includes("Cinema 4D")) {
|
||||
str = str[1].split("[")
|
||||
//If for some reason the name isnt right?
|
||||
if (!str[1]) return
|
||||
str = str[1].split("]")
|
||||
if (str[0].includes("*")) {
|
||||
str = str[0].substring(0, str[0].length - 2)
|
||||
|
@ -60,13 +63,23 @@ function setDRCProject() {
|
|||
//reconnects the client if isnt connected
|
||||
if (!clientIsConnected) {
|
||||
currentClient = client("936296341250904065")
|
||||
currentClient.on("error", (err) => {
|
||||
//console.log("err")
|
||||
})
|
||||
|
||||
clientIsConnected = true
|
||||
//console.log("starting client")
|
||||
currentProject = "0"
|
||||
}
|
||||
|
||||
currentClient.on("error", (err) => {
|
||||
//if errored and shouldnt have, reconnect
|
||||
if (clientIsConnected && currentProject) {
|
||||
currentClient = client("936296341250904065")
|
||||
console.log("errored and reconnecting")
|
||||
} else {
|
||||
clientIsConnected = false, currentProject = false
|
||||
console.log("errored and keeping off")
|
||||
}
|
||||
})
|
||||
|
||||
if (currentProject != pastProject) {
|
||||
currentClient.updatePresence({
|
||||
state: `Porfolio: ${DRCSettings.portfolio_website}`,
|
||||
|
@ -85,7 +98,7 @@ function setDRCProject() {
|
|||
async function main() {
|
||||
while (true) {
|
||||
updateOpenProjectName(await getCinemaProcessInfo())
|
||||
//stops DRC when broken
|
||||
//stops DRC when no project detected
|
||||
if (currentProject == false) {
|
||||
if (clientIsConnected) {
|
||||
await currentClient.disconnect()
|
||||
|
|
Loading…
Reference in a new issue