mpv-discord icon indicating copy to clipboard operation
mpv-discord copied to clipboard

Discord rate limits the update frequency of the presence

Open ghost opened this issue 3 years ago • 12 comments

After a little bit, Discord starts to ratelimit the AV: line, plus it's mostly useless because of the "xx:xx left" line (which isn't rate limited due to it being set once) anyway. This also means that it won't receive events for pausing once rate limited, causing it to keep counting down even after pausing. image

ghost avatar May 29 '21 04:05 ghost

Is there any update on this issue?

Kruchji avatar Jan 23 '22 17:01 Kruchji

The video progress (the AV: 00:01:19/00:51:08 row) in Rich Presence requires frequent updates to keep it real time. But I don't think there is a workaround to bypass Discord's rate limit. Perhaps a solution to this issue is to use something else rather than video progress for the text.

Any suggestions on what the text could be?

tnychn avatar Jan 24 '22 06:01 tnychn

Would it be possible to add an option (maybe in the config) to update the video progress less frequently?

e.g. every 10 seconds, so Discord's rate limit wouldn't come into effect

Kruchji avatar Jan 24 '22 15:01 Kruchji

Yes, that would be a great solution. I will try to implement it when I'm free.

tnychn avatar Jan 27 '22 21:01 tnychn

I don't know much about go so I just changed https://github.com/tnychn/mpv-discord/blob/663f0e3ee1fa81c9833444d9bd8e40583e39bb29/mpv-discord/main.go#L155

to:

   for range time.Tick(10 * time.Second) {

😄

The docs state that:

This has a rate limit of 5 updates per 20 seconds. https://discord.com/developers/docs/game-sdk/activities#updateactivity

So 10 seconds should be fine.

Don't know how much value there is in making in configurable?

zeratax avatar Jun 22 '22 20:06 zeratax

Actually still gets rate limited, just later lol ^^

zeratax avatar Jun 22 '22 23:06 zeratax

Maybe the rate needs to be even lower?

But also games like League of Legends show exact time of match so there probably is another way of doing this

Kruchji avatar Jun 23 '22 10:06 Kruchji

It's already implemented inside of the rich presence, so the easiest way would just be to either remove the line or retool it into something more.. useful.

ghost avatar Jun 23 '22 11:06 ghost

yeah that's what I was thinking about too. just deprecate that line and instead of updating based on an interval, updating after an action (pause,play,change title, etc) is performed.

side note: also created an action to build the binaries and attach them to releases if a tag is pushed https://github.com/tnychn/mpv-discord/commit/5ce0105391c4b28343cedc66077a16f85b2f75fd should probably put that on it's own branch and create a pr.

zeratax avatar Jun 23 '22 13:06 zeratax

Throwing my hat into the ring here to say that I was even blocked by Cloudflare after around 2 hours:

My only guess is that Cloudflare thinks that it was an attempted DoS due to the amount of calls sent to the servers.
Now, while it's definitely possible that this didn't result from this integration, I've never got something like this in all my years of using Discord (even with spamming the Discord servers myself a bit) and it only appeared after starting to use this integration.

I honestly think that this is f*cking hilarious, but this is definitely a problem lmao

mfederczuk avatar Sep 29 '23 11:09 mfederczuk

Throwing my hat into the ring here to say that I was even blocked by Cloudflare after around 2 hours:

My only guess is that Cloudflare thinks that it was an attempted DoS due to the amount of calls sent to the servers. Now, while it's definitely possible that this _didn't_ result from this integration, I've never got something like this in all my years of using Discord (even with spamming the Discord servers myself a bit) and it only appeared after starting to use this integration.

I honestly think that this is f*cking hilarious, but this is definitely a problem lmao

This was a global problem just over an hour ago, unrelated to this tool 👍

Reinbowsaur avatar Sep 29 '23 11:09 Reinbowsaur

This was a global problem just over an hour ago, unrelated to this tool 👍

Ah, then I apologize. 🙇🏻
Unfortunate timing for me to start using this.

mfederczuk avatar Sep 29 '23 11:09 mfederczuk