RichPresenceAPI
'discord-rpc-csharp' for BepInEx plugin
Last updated | 2 years ago |
Total downloads | 1297 |
Total rating | 1 |
Categories | Libraries |
Dependency string | xhayper-RichPresenceAPI-0.0.7 |
Dependants | 1 other package depends on this package |
README
RichPresenceAPI
'discord-rpc-csharp' for Unity BepInEx plugin
Why use this instead of 'discord-rpc-csharp' directly?
- Unity broke the 'Named Pipe Client Stream' that 'discord-rpc-charp' use, 'discord-rpc-charp' recommended us to install a alternative called 'NativeNamedPipe' which is a pain in the ass to install, So this plugin simplify it.
Why Unity version '2019.4.24'?
- This was originally planned to be used for 'Inscryption', Hence the '2019.4.2'
Example Usage
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();
}
}
}
Compile process
- First, you need to re-compile the 'NativeNamedPipe' in 'amd64_x86', because the version that 'discord-rpc-csharp' provied with is 'x86_amd64', then, put the compiled DLL in the same folder as 'RichPresenceAPI.dll'.
- You need to download discord-rpc-charp's DLL, and Newtonsoft.Json's DLL, and put it in the same folder as 'RichPresenceAPI.dll'.