discord-rpc-csharp
discord-rpc-csharp copied to clipboard
[BUG] client.ClearPresence(); dont work
Describe the bug A clear and concise description of what the bug is. This code dont work,activity continues to hang for about a minute
client.SetPresence(null);
client.ClearPresence();
I am also having the same issue
I am also having the same issue
Forget it, the ticket has been open for almost a year now. Look for another library.
wow rude, dont tell people to use other libraries within the help of this one.
Your issue is invalid anyways, please follow the issue templates next time. Dont know the bug, or what you are expecting. "This code dont work" is not very descriptive. I am unable to reproduce this issue, so any help you can provide is more than welcomed.
I will help however, to get this finally ticked away.
- Starters, doing both SetPresence and ClearPresence here is redundant, as they both set it to null.
- ClearPresence works on my end, please provide code to replicate your issue.
- Ensure you are not later setting the presence elsewhere.
- Enable the logs and share them here so i can validate the code is actually sending the clear
I am unable to reproduce this issue, so any help you can provide is more than welcomed.
Hi, sorry as I just saw these comments now 10 months later. If it is worth anything, I had kept using this library since I think it is quite a good one. The way that this bug had occured is the following:
- Load a rich presence using this package
- Start another rich presence (for example Spotify)
- Deactivate the rich presence from this package
- Deactivate the other rich rpesence
- The rich presence from this package will "ghost" and keep staying on.
It's an edge case, definitely but some use cases, such as mine, had it more often.
In any case, I had also found that this wasn't even local to the rich presences from this package only! Even other rich presences, during the time, had ghosting issues. I think since the time that Discord had updated their rich presences, this issue has mostly subsided and I haven't noticed it happening with any presence (including attempting to force it).
The problem definitely exists, the fix for me was is I had to make a little delay after calling ClearPresence and Dispose.
protected override void OnClosing(WindowClosingEventArgs e)
{
rpcClient.ClearPresence();
rpcClient.Dispose();
Task.Delay(200).Wait(); // Fixes the issue with Discord RPC not closing properly
base.OnClosing(e);
}
The problem definitely exists, the fix for me was is I had to make a little delay after calling ClearPresence and Dispose.
protected override void OnClosing(WindowClosingEventArgs e) { rpcClient.ClearPresence(); rpcClient.Dispose(); Task.Delay(200).Wait(); // Fixes the issue with Discord RPC not closing properly base.OnClosing(e); }
Thanks, Ill see if I can reproduce this
If you launch the app via its executable instead running it from the IDE, then the presence will be cleared when closing the application, but when you try to clear the presence during runtime it will not be cleared. For example using a button for clearing the presence will not actually clear the presence, until the application is closed.
Detailed steps to reproduce the issue: 0. Create an Avalonia Desktop Application.
- Add DiscordRichPresence (1.6.1.70) through nuget
- Add the following code to MainWindow.axaml.cs
private DiscordRpcClient rpcClient;
protected override void OnOpened(EventArgs e)
{
base.OnOpened(e);
rpcClient = new DiscordRpcClient("your-client-id-here");
rpcClient.Initialize();
rpcClient.SetPresence(new RichPresence
{
Details = "Testing....",
Timestamps = Timestamps.Now,
Assets = new Assets
{
LargeImageKey = "logo",
LargeImageText = "Test App",
}
});
}
protected override void OnClosing(WindowClosingEventArgs e)
{
rpcClient.ClearPresence();
rpcClient.Dispose();
base.OnClosing(e);
}
- Launch the app and check discord.
- Close the app
- The presence did not get cleared.
Extra Information:
- OS: Arch Linux
- IDE: JetBrains Rider
- Discord Client: Vesktop
- The Task.Delay(200).Wait() stopped working since I posted my previous message. Setting it higher does not help.