'discord-rpc-csharp' for Unity BepInEx plugin
using RichPresenceAPI.Logging;
using DiscordRPC.Logging;
using RichPresenceAPI;
using DiscordRPC;
using BepInEx;
namespace ExamplePlugin
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
[BepInDependency("io.github.xhayper.RichPresenceAPI")]
public class Plugin : BaseUnityPlugin
{
private DiscordRpcClient client;
private void Awake()
{
client = RichPresenceAPI.Utility.CreateDiscordRpcClient(my_client_id);
//Set the logger
client.Logger = new BepInExLogger(Logger)
{
Level = LogLevel.Trace
};
//Connect to the RPC
client.Initialize();
//Set the rich presence
//Call this as many times as you want and anywhere in your code.
client.SetPresence(new RichPresence()
{
Details = "Example Project",
State = "csharp example",
Assets = new Assets()
{
LargeImageKey = "image_large",
LargeImageText = "Lachee's Discord IPC Library",
SmallImageKey = "image_small"
}
});
}
private void OnDestroy()
{
client.Dispose();
}
}
}