Froststrap.DiscordRPC
1.0.0
dotnet add package Froststrap.DiscordRPC --version 1.0.0
NuGet\Install-Package Froststrap.DiscordRPC -Version 1.0.0
<PackageReference Include="Froststrap.DiscordRPC" Version="1.0.0" />
<PackageVersion Include="Froststrap.DiscordRPC" Version="1.0.0" />
<PackageReference Include="Froststrap.DiscordRPC" />
paket add Froststrap.DiscordRPC --version 1.0.0
#r "nuget: Froststrap.DiscordRPC, 1.0.0"
#:package Froststrap.DiscordRPC@1.0.0
#addin nuget:?package=Froststrap.DiscordRPC&version=1.0.0
#tool nuget:?package=Froststrap.DiscordRPC&version=1.0.0
DiscordRPC
A high-performance, Native AOT-compatible Discord Rich Presence client for .NET 10.0.
Features
- Native AOT compatibility with zero reflection.
- System.Text.Json source generation for JSON serialization and deserialization.
- No external dependencies.
- Cross-platform support for Windows, Linux, and macOS.
- Custom JSON converters for Discord API compatibility.
- Improved named pipe connection handling with a connection timeout.
- Compatible with trimming.
Installation
Install the package using the .NET CLI:
dotnet add package Froststrap.DiscordRPC
Usage
csharp
using DiscordRPC;
using DiscordRPC.Logging;
var client = new DiscordRpcClient("YOUR_APPLICATION_ID")
{
Logger = new ConsoleLogger() { Level = LogLevel.Info }
};
client.OnReady += (sender, e) =>
{
Console.WriteLine($"Connected to Discord as {e.User.Username}");
};
client.Initialize();
client.SetPresence(new RichPresence()
{
Details = "Playing a game",
State = "In a match",
Timestamps = new Timestamps()
{
Start = DateTime.UtcNow
},
Assets = new Assets()
{
LargeImageKey = "large_image",
LargeImageText = "My Game",
SmallImageKey = "small_image",
SmallImageText = "Level 10"
}
});
// Keep the application running
Console.ReadLine();
client.Dispose();
Replace YOUR_APPLICATION_ID with your Discord application's ID.
Changes from the Original Project
This project is based on Lachee/discord-rpc-csharp and includes modifications to support Native AOT and improve compatibility with Discord's API.
JSON Deserialization
The original implementation had issues deserializing certain Discord API fields because the API can return numeric values as strings.
Custom JSON converters have been added to handle these fields:
UlongStringConverter: Handles Discord snowflake IDs returned as strings.IntStringConverter: Handles discriminator values returned as strings.EnumStringConverter<T>: Handles enum fields such as flags and premium_type.
These converters improve compatibility with Discord's API while supporting source-generated JSON serialization.
Named Pipe Connection Timeout
A five-second timeout has been added to named pipe connections to prevent indefinite blocking.
csharp
_stream.Connect(5000);
Previously, the connection used:
csharp
_stream.Connect(0);
Enum Serialization
JsonStringEnumConverter<T> has been added to the Command and ServerEvent enums to ensure proper Discord protocol serialization.
Main Differences
| Feature | Original | This Fork |
|---|---|---|
| Native AOT | Not supported | Supported |
| JSON Library | Newtonsoft.Json | System.Text.Json |
| JSON Serialization | Runtime-based | Source-generated |
| User Field Handling | Original conversion | Custom JSON converters |
| Pipe Connection | No timeout | Five-second timeout |
| Trimming | Not supported | Supported |
Requirements
- .NET 10.0 or later.
- Discord Desktop Client running.
Native AOT Publishing
To publish an application using Native AOT, run:
bash
dotnet publish -c Release -r win-x64 --self-contained
Replace win-x64 with the appropriate runtime identifier for your target platform.
Releasing
Two workflows handle releases:
.github/workflows/build.ymlruns on every push and pull request. It restores, builds, tests, and packs the project. When you push a tag that starts withv(for examplev1.0.0) and the build succeeds, it also creates the matching GitHub Release..github/workflows/publish.ymlruns afterbuild.ymlfinishes. When the trigger was av*tag and the build succeeded, it packs and pushes the package to NuGet.org using OIDC trusted publishing (no stored API key).
To release a new version:
Bump
<Version>inDiscordRPC-NativeAOT.csproj.Commit and push.
Push a tag matching that version, for example:
git tag v1.0.0 git push origin v1.0.0
That creates the GitHub Release and publishes the package automatically.
Before the first automated release, add a trusted publishing policy on nuget.org pointing at this repository and the publish.yml workflow file, and set a NUGET_USER repository secret in GitHub to the nuget.org username of the person who created that policy.
License
This project is licensed under the MIT License, following the original discord-rpc-csharp project.
See the LICENSE file for details.
Credits
Original project: Lachee/discord-rpc-csharp.
This fork contains modifications for Native AOT compatibility, JSON serialization, and connection handling.
Issues
Report bugs and compatibility issues through the GitHub Issues page.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 698 | 11/17/2026 |
Initial Froststrap release of DiscordRPC-NativeAOT.