Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
560 stars 94 forks source link

[BUG] endTimestamp-less elapsed mode payload construction incorrect? #139

Closed Kein closed 3 years ago

Kein commented 3 years ago

Describe the bug Specifying only startTimestamp forces RichPresence to have forever bugged 00:00

To Reproduce Steps to reproduce the behavior:

  1. Create basic RichPresence
  2. Populate State, Details and StartTimestamp
  3. Send
  4. Check broken timer in rich presence in the client

Expected behavior According to docs, if endTimestamp is not send, elapsed mode is used, starting from startTimestamp

Desktop (please complete the following information):

Lachee commented 3 years ago

Hello, what are you setting startTimestamp too? Can you please provide a code sample.

Kein commented 3 years ago
presence = new RichPresence();
presence.State = MAINMENU;
presence.Details = string.Empty;
presence.Timestamps = new Timestamps(DateTime.Now, null);
presence.Assets = new DiscordRPC.Assets();
presence.Assets.LargeImageKey = "logo";
client.SetPresence(presence);   

I switched back to native lib with basic wrapper around it - it works as expected, if only start timestamp is sent then it uses "elapsed" mode. It does not matter what I set EndTime to, I tried multiple. I debugged and confirmed it is never sent in serialized payload if set to null so I dunno what gives.

Lachee commented 3 years ago

Timestamps is UTC. Please use DateTime.UtcNow.

Alternatively, there is a shortcut property: Timestamps.Now https://github.com/Lachee/discord-rpc-csharp/blob/master/DiscordRPC/RichPresence.cs#L485