brakacai / discord-ghost

Headless Discord-RPC for Destiny
MIT License
75 stars 14 forks source link

I fixed #31 for you (for the most part) (edit - for PC players) #40

Open ghost opened 5 years ago

ghost commented 5 years ago

for reference: #31

I felt like this should be fixed so I found a way to fix it. It's fixed under the assumption that you're running discord, destiny, and this script on the same computer. I say for the most part because there isn't anything you can do when someone is starting up the game. The script sees the game running so it goes to the API to get their status (which is wrong). If they shut down the game or start the script before they launch destiny, it does not claim they are on destiny.

Changes:

Example output:

C:\code\gitbase\discord-ghost>npm start

> @brakacai/discord-ghost@0.0.4-development start C:\code\gitbase\discord-ghost
> node ./dist/index.js

Config file found
Starting service
Destiny2 is not running.
cleared rpc.
Destiny2 is not running.
cleared rpc.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
Destiny2 is not running.
cleared rpc.
Destiny2 is not running.
cleared rpc.

Code is here: https://apx.gg/files/discord-ghost-src.zip

disclaimer - i'm a very experienced c# dev who has only dabbled in node.js. i do not know what i am doing, but i can make things work.

louis-bompart commented 5 years ago

Hey ! I'm quite interested, would you mind opening a PR so I can review that properly?

ghost commented 5 years ago

I haven't used github since college so I might be doing this wrong, but it looks like I need write access to upload the new branch.

ghost commented 5 years ago

nvm, figured it out. I made the pull request #49

It looks like visual studio's auto formatting messed with the spacing on the lines though so it isnt as easy to compare.

ghost commented 5 years ago

i tried to make it easier to compare. i'm really just messing around at this point

https://github.com/Akumati1435/discord-ghost/compare/master...Akumati1435:master-with-VS-line-formatting?expand=1

that should show you the oppose of the changes. red is green and green is red

edit: nvm, this comparison thing broke.

louis-bompart commented 5 years ago

I forked your branch and I'm taking time to thinks this over properly. This change, semantically speaking, is a breaking change (change in behavior). So I want to fix this once and for all, for everyone.

My current idea is the following: Poke the API with an incremental delay (15s,30s,1m,2m,5m,15m,30m,1h,2h). If activity is detected then reset the delay. If no activity is detected after reaching the max delay, then start a final countdown of 24hrs. In the mean time, keep poking the API every MAX_DELAY (2hrs I'd say) If the player is playing on PC (membershipType===4), on destiny 2 exe launch(and only on launch, i.e. first detection), reset the final countdown and the delay. If the player quit the app (process not detected anymore), I'll certainly try to bust the cache (sorry Bungie!), now that I know it's possible. Thus allowing us to return to the routine (poke the api, increment timer and monitor process)

louis-bompart commented 5 years ago

Update, this one is almost next on my hit list. Sorry for the long wait, security and privacy were my upmost priorities

Robinhubbard31 commented 5 years ago

It looks like everyone is doing a great job but I need to know what is happening?

sirloveshatambaya commented 5 years ago

Yes good job

louis-bompart commented 5 years ago

I'm not sure to understand your question @Robinhubbard31