MysteryPancake / Discord-Reposter

Bot for reposting Discord messages (work in progress)
MIT License
92 stars 121 forks source link

Random Closing #13

Open CyaOnDaNet opened 5 years ago

CyaOnDaNet commented 5 years ago

I have been running this successfully but usually after running it for 12-48 hours it closes itself. I don't know if its crashing or throwing an error because there is nothing open on the machine. I'll simply notice the bot is offline in discord and check the machine and the command line window will just be gone. I have other bots running on the machine so I doubt it is an issue with my machine, discord, node js, etc. Is there a debugger I can enable to figure out why this is happening?

MysteryPancake commented 5 years ago

I noticed this bot seems to randomly stop working on Heroku as well. I think it may be crashing due to Discord's rate limits, but I'm not certain.

One thing which may help with debugging would be overriding console.error so it logs the error to a file rather than the console, this should log errors to a new file called reposterrors.log if you add it to the very bottom of reposter.js:

console.error = function(msg) {
    fs.appendFileSync("reposterrors.log", msg);
}
CyaOnDaNet commented 5 years ago

I added that at the very end and it doesn't make that log file. Its closed/crashed twice since I added that about 5 days ago. The end of my reposter.js looks like this:

});

console.error = function(msg) { fs.appendFileSync("reposterrors.log", msg); }

MysteryPancake commented 5 years ago

If there are no errors, I think this is probably due to the method the bot uses to force messages to stop sending. At the moment inactive(from, to) is used to ensure nothing sends if a channel isn't active. This is probably causing a lot of bugs. I will try to find a better method, since I noticed this sometimes happens for me as well

CyaOnDaNet commented 5 years ago

I was able to use the npm package forever to create a log of the console as well as try to keep it running. The first time it crashed it gave the following error: `events.js:188 throw err; ^

Error: Unhandled "error" event. ([object Object])`

Unfortunately, forever failed to restart the program giving different errors. I attached the log but redacted some info from an Authorization line that I thought might be sensitive info

Reposter_Log_OkJf.log .