RichPresenceAPI

版本 v0.0.7·更新於 2022-03-22

'discord-rpc-csharp' for BepInEx plugin

模組介紹 作者原文

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

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

檔案與校驗

檔案名稱
RichPresenceAPI-0.0.7.zip
檔案大小
310.2 KiB