Froststrap.DiscordRPC 1.0.0

dotnet add package Froststrap.DiscordRPC --version 1.0.0
                    
NuGet\Install-Package Froststrap.DiscordRPC -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Froststrap.DiscordRPC" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Froststrap.DiscordRPC" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Froststrap.DiscordRPC" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Froststrap.DiscordRPC --version 1.0.0
                    
#r "nuget: Froststrap.DiscordRPC, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Froststrap.DiscordRPC@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Froststrap.DiscordRPC&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Froststrap.DiscordRPC&version=1.0.0
                    
Install as a Cake Tool

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:

  1. .github/workflows/build.yml runs on every push and pull request. It restores, builds, tests, and packs the project. When you push a tag that starts with v (for example v1.0.0) and the build succeeds, it also creates the matching GitHub Release.
  2. .github/workflows/publish.yml runs after build.yml finishes. When the trigger was a v* 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:

  1. Bump <Version> in DiscordRPC-NativeAOT.csproj.

  2. Commit and push.

  3. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.