RichPresenceAPI

v0.0.7·Updated 2022-03-22

'discord-rpc-csharp' for BepInEx plugin

About this mod Author’s original text

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'.

See also

  • discord-rpc-charp's README

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

File & checksum

Filename
RichPresenceAPI-0.0.7.zip
File size
310.2 KiB