Open Founntain opened 3 years ago
I'll look into this and see if I can reproduce it. Are you able to provide a code snippet that reproduces this issue?
Code Snipptes
Client.Invoke() isn't called manually by me because of AutomaticeInvoke is set to true (by default)
I hope these will help you. If you need anything please tell I try to give you as much info as I possible can.
private DiscordRpcClient Client;
private RichPresence Presence;
//Initializing the client
private void Initialize()
{
Debug.WriteLine("Creating... Discord Client");
Client = new DiscordRpcClient(ClientId)
{
Logger = new ConsoleLogger {Level = DiscordLogLevel}
};
Debug.WriteLine("Subscribing Discord events...");
Client.OnReady += OnReady;
Client.OnClose += OnClose;
Client.OnError += OnError;
Client.OnConnectionEstablished += OnConnectionEstablished;
Client.OnConnectionFailed += OnConnectionFailed;
Client.OnPresenceUpdate += OnPresenceUpdate;
Client.OnSubscribe += OnSubscribe;
Client.OnUnsubscribe += OnUnsubscribe;
Client.OnJoin += OnJoin;
Client.OnJoinRequested += OnJoinRequested;
Client.SetSubscription(EventType.Join | EventType.JoinRequest);
Client.Initialize();
Debug.WriteLine("Discord Initialize finished...\n");
}
//Method to update the current Discord RPC
public void UpdatePresence(string details, string state, int partySize, string joinSecret)
{
var presence = new RichPresence
{
Details = details,
State = state,
Assets = new Assets { },
Party = new Party {ID = OsuPlayer.PartyManager.PartyId ?? string.Empty, Size = partySize, Max = 256}
};
presence.Secrets = new Secrets
{
JoinSecret = joinSecret
};
Client.SetPresence(presence);
}
I am currently hitting this bug aswell, my code:
public class MainMod : MelonMod
{
public static DiscordRpcClient client;
public static MelonLogger.Instance Logger;
private float timer = 0.0f;
public float period = 15f;
public override void OnApplicationLateStart()
{
Logger = LoggerInstance;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (client == null)
{
client = new DiscordRpcClient("925431370577231974", client: new UnityNamedPipe())
{
Logger = new LoggerPassthrough()
};
client.OnReady += (sender, e) =>
{
LoggerInstance.Msg("Received Ready from user " + e.User.Username);
client.SetPresence(new RichPresence()
{
State = "Idle",
Assets = new DiscordRPC.Assets()
{
LargeImageKey = "big-image"
}
});
};
client.OnPresenceUpdate += (sender, e) =>
{
LoggerInstance.Msg("Received Update! " + e.Presence);
};
client.Initialize();
}
}
public override void OnUpdate()
{
timer += Time.deltaTime;
if (timer > period)
{
timer = timer - period;
LoggerInstance.Msg("Tick RPC");
Logger.Msg(String.Format("{0}/15 | {1} | {2}", Hooks._big.CurrentRoom.RemoteUsers.Count, Hooks._big.CurrentRoom.Name, Hooks._big.CurrentRoom.Visibility));
Logger.Msg(Hooks._big.CurrentRoom.Environment);
client.ClearPresence();
client.SetPresence(new RichPresence()
{
State = String.Format("{0}/15 | {1} | {2}", Hooks._big.CurrentRoom.RemoteUsers.Count, Hooks._big.CurrentRoom.Name, Hooks._big.CurrentRoom.Visibility),
Details = Hooks._big.CurrentRoom.Environment,
Assets = new DiscordRPC.Assets()
{
LargeImageKey = "big-image"
}
});
}
}
public override void OnApplicationQuit()
{
client.Dispose();
}
}
Manually client.Invoke()
ing doesn't do any difference.
@Founntain Did you get it fixed or?
Seems to be linked to #84
@Founntain Did you get it fixed or?
Well I can't tell. I really waited for an response to that. And I have to say sometimes it just keeps working fine and sometimes it doesn't have to check tho.
Is there any update on this? @Lachee
This library isn't broken or deprecated. The core library is working fine, if there is an issue its likely just the Unity package. If you are able to provide logs with the latest package, then please share them as they will be better able to diagnose the issue.
Im using this for Unity via a modloader, specifically MelonLoader - I've imported UnityNamedPipe - there are no logs because it works as intended, just the presence doesn't change after 1 update
Describe the bug After initializing the client and setting the RPC for the first time it works totally fine. Updating the presence doesn't work anymore. Worked perfectly fine before. Looking inside the OnPresenceUpdate the presence got updated, but the discord client doesn't show the updated RPC
To Reproduce Steps to reproduce the behavior:
Expected behavior The discord client should change the presence to the according data
Desktop (please complete the following information):
Additional context First RPC (correct)
Second presence (Not updated) Should be LA FESTA LA VITA by GUHROOVY
Data from OnPresenceUpdate Screenshot after successfull update
I also want to mention that it worked totally fine I just noticed it now. No code changes made. If I have to change something because of changes of the RPC, please let me know.