### Basic Discord Rich Presence Setup
Source: https://lachee.github.io/discord-rpc-csharp/index.html
This example demonstrates the basic setup for initializing the DiscordRpcClient, handling the OnReady event, setting a Rich Presence with details, state, assets, and buttons, and finally disposing of the client.
```csharp
using DiscordRPC;
public const string DISCORD_APP_ID = "424087019149328395";
public static DiscordRpcClient client;
public static void Main()
{
// Create the client and setup some basic events
client = new DiscordRpcClient(DISCORD_APP_ID)
{
Logger = new Logging.ConsoleLogger(Logging.LogLevel.Info, true)
};
client.OnReady += (sender, e) =>
{
Console.WriteLine("Connected to discord with user {0}", msg.User.Username);
Console.WriteLine("Avatar: {0}", msg.User.GetAvatarURL(User.AvatarFormat.WebP));
Console.WriteLine("Decoration: {0}", msg.User.GetAvatarDecorationURL());
};
//Connect to the RPC
client.Initialize();
//Set the rich presence
client.SetPresence(new RichPresence()
{
Details = "A Basic Example",
State = "In Game",
Assets = new Assets()
{
LargeImageKey = "image_large",
LargeImageText = "Lachee's Discord IPC Library",
SmallImageKey = "image_small"
},
Buttons = new Button[]
{
new Button() { Label = "lachee.dev", Url = "https://lachee.dev/" }
}
});
// ... Do Stuff ...
Console.ReadKey();
// Cleanup
client.Dispose();
}
```
--------------------------------
### Run Example Project
Source: https://lachee.github.io/discord-rpc-csharp/index.html
This command executes the 'Basic' example from the DiscordRPC.Example project using .NET 9.
```bash
dotnet run --framework net9 --project DiscordRPC.Example --example=Basic
```
--------------------------------
### Run Basic Example Project
Source: https://lachee.github.io/discord-rpc-csharp/articles/getting_started/introduction.html
Execute the basic example provided in the DiscordRPC.Example project using the dotnet CLI to see Rich Presence in action.
```bash
dotnet run --framework net9 --project DiscordRPC.Example --example=Basic
```
--------------------------------
### Start Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Gets or sets the time the match started. When set, displays 'elapsed' time in the rich presence.
```csharp
[JsonIgnore]
public DateTime? Start { get; set; }
```
--------------------------------
### Run Discord RPC Example for Joining
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/joining.html
Execute the Discord RPC example project to test the joining flow using separate pipes. This demonstrates the use of two distinct clients.
```bash
# Run on the first pipe
dotnet run --framework net9 --project DiscordRPC.Example --example=Joining --pipe=0
# Run on the second pipe
dotnet run --framework net9 --project DiscordRPC.Example --example=Joining --pipe=1
```
--------------------------------
### Timestamps Constructor with Start Time
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Creates a Timestamps object with a specified start time.
```csharp
public Timestamps(DateTime start)
```
--------------------------------
### GetSteamLocation Method
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.WindowsUriScheme.html
Retrieves the installation path of the Steam client on the Windows system.
```csharp
public string GetSteamLocation()
```
--------------------------------
### StartUnixMilliseconds Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Converts between DateTime and Milliseconds for the Start time, providing Unix Epoch time.
```csharp
[JsonProperty("start", NullValueHandling = NullValueHandling.Ignore)]
public ulong? StartUnixMilliseconds { get; set; }
```
--------------------------------
### Update Rich Presence Start Time
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start time of the current Rich Presence to the current time and sends the update to Discord. Returns the updated Rich Presence object.
```csharp
public RichPresence UpdateStartTime()__
```
--------------------------------
### UpdateStartTime()
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start time of the CurrentPresence to now and sends the updated presence to Discord. Returns the updated Rich Presence object.
```APIDOC
## UpdateStartTime()
### Description
Sets the start time of the CurrentPresence to now and sends the updated presence to Discord.
### Returns
RichPresence - Updated Rich Presence
```
--------------------------------
### Update Rich Presence Start Time with Specific Time
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start time of the current Rich Presence to a specified DateTime and sends the update to Discord. Returns the updated Rich Presence object.
```csharp
public RichPresence UpdateStartTime(DateTime time)__
```
--------------------------------
### Get Configuration
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Accesses the current connection configuration. This property is only available after a 'ready' event has been received.
```csharp
public Configuration Configuration { get; }
```
--------------------------------
### Timestamps Constructor with Start and End Time
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Creates a Timestamps object with specified start and end times.
```csharp
public Timestamps(DateTime start, DateTime end)
```
--------------------------------
### Timestamps Constructors
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Provides constructors for creating Timestamps objects, either empty, with a start time, or with both start and end times.
```APIDOC
## Constructors
### Timestamps()
Creates an empty timestamp object.
```csharp
public Timestamps()
```
### Timestamps(DateTime start)
Creates a timestamp with the set start time.
```csharp
public Timestamps(DateTime start)
```
#### Parameters
`start` DateTime
### Timestamps(DateTime start, DateTime end)
Creates a timestamp with a set duration.
```csharp
public Timestamps(DateTime start, DateTime end)
```
#### Parameters
`start` DateTime
The start time
`end` DateTime
The end time
```
--------------------------------
### UpdateStartTime(DateTime)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start time of the CurrentPresence to a specified DateTime and sends the updated presence to Discord. Returns the updated Rich Presence object.
```APIDOC
## UpdateStartTime(DateTime)
### Description
Sets the start time of the CurrentPresence and sends the updated presence to Discord.
### Parameters
#### Path Parameters
- **time** (DateTime) - Required - The new time for the start
### Returns
RichPresence - Updated Rich Presence
```
--------------------------------
### Now Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Provides a new Timestamps object that starts from the current time.
```csharp
public static Timestamps Now { get; }
```
--------------------------------
### Get User Avatar URL (Default)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets the URL for the user's avatar as a PNG. If no avatar is set, a default avatar URL is returned. The image will be 128x128px.
```csharp
public string GetAvatarURL()
```
--------------------------------
### Add DiscordRichPresence Package
Source: https://lachee.github.io/discord-rpc-csharp/articles/getting_started/introduction.html
Install the DiscordRichPresence NuGet package to your .NET project using the dotnet CLI.
```bash
dotnet add package DiscordRichPresence
```
--------------------------------
### ManagedNamedPipeClient.GetPipeSandbox (Obsolete)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Obsolete method to get the current pipe sandbox. Use PipePermutation.GetPipes instead.
```csharp
[Obsolete("Use PipePermutation.GetPipes instead", true)]
public static string GetPipeSandbox()
```
--------------------------------
### Get User Avatar URL (With Format)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets the URL for the user's avatar in the specified format. If no avatar is set, a default avatar URL is returned. The default avatar only supports PNG format.
```csharp
public string GetAvatarURL(User.AvatarFormat format)
```
--------------------------------
### PipeFrame.Message
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the data represented as a string.
```APIDOC
## Message
### Description
The data represented as a string.
### Property Value
- **string**
```
--------------------------------
### PipeFrame.Opcode
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the opcode of the frame.
```APIDOC
## Opcode
### Description
The opcode of the frame.
### Property Value
- **Opcode**
```
--------------------------------
### Get User Avatar Decoration URL (No Format)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Retrieves the URL for the user's avatar decoration. The image will be an Animated PNG.
```csharp
public string GetAvatarDecorationURL()
```
--------------------------------
### Get Avatar Extension
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Returns the file extension for a given avatar format.
```csharp
public string GetAvatarExtension(User.AvatarFormat format)
```
--------------------------------
### Get User Avatar Decoration URL (With Format)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Retrieves the URL for the user's avatar decoration with a specified format. Note that size is not supported and formats like GIF and WebP have specific behaviors.
```csharp
public string GetAvatarDecorationURL(User.AvatarFormat format)
```
--------------------------------
### File Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.FileLogger.html
Gets or sets the path of the log file. This property is used to specify where the log messages will be written.
```csharp
public string File { get; set; }
```
--------------------------------
### Connect Method
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.INamedPipeClient.html
Attempts to establish a connection to a specified pipe. If -1 is provided, it searches for the first available pipe.
```csharp
bool Connect(int pipe)
```
--------------------------------
### Initialize DiscordRpcClient
Source: https://lachee.github.io/discord-rpc-csharp/articles/getting_started/introduction.html
Create and initialize the DiscordRpcClient once in your application's lifetime. Ensure it's treated as a singleton to avoid conflicts.
```csharp
public DiscordRpcClient Client { get; private set; }
void Setup() {
Client = new DiscordRpcClient("my_client_id"); //Creates the client
Client.Initialize(); //Connects the client
}
```
--------------------------------
### WindowsUriScheme Constructors
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.WindowsUriScheme.html
Initializes a new instance of the WindowsUriScheme class.
```APIDOC
## WindowsUriScheme(ILogger)
### Description
Initializes a new instance of the WindowsUriScheme class.
### Parameters
#### Parameters
- **logger** (ILogger) - Description: The logger instance to use for the WindowsUriScheme.
```
--------------------------------
### DiscordRpcClient Constructor with Advanced Options
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Initializes a new instance of the DiscordRpcClient class with advanced configuration options.
```APIDOC
## DiscordRpcClient(string, int, ILogger, bool, INamedPipeClient)
### Description
Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join events. This constructor exposes more advance features such as custom NamedPipeClients and Loggers.
### Parameters
#### Parameters
- **applicationID** (string) - The ID of the application created at discord's developers portal.
- **pipe** (int) - The pipe to connect too. If -1, then the client will scan for the first available instance of Discord. (Optional, defaults to -1)
- **logger** (ILogger) - The logger used to report messages. If null, then a NullLogger will be created and logs will be ignored. (Optional, defaults to null)
- **autoEvents** (bool) - Should events be automatically invoked from the RPC Thread as they arrive from discord? (Optional, defaults to true)
- **client** (INamedPipeClient) - The pipe client to use and communicate to discord through. If null, the default ManagedNamedPipeClient will be used. (Optional, defaults to null)
```
--------------------------------
### UnixUriScheme Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.UnixUriScheme.html
Initializes a new instance of the UnixUriScheme class, requiring an ILogger for logging purposes.
```APIDOC
## UnixUriScheme(ILogger)
### Description
Initializes a new instance of the UnixUriScheme class.
### Parameters
#### Parameters
- **logger** (ILogger) - Description for logger parameter.
```
--------------------------------
### UnixUriScheme Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.UnixUriScheme.html
Initializes a new instance of the UnixUriScheme class, requiring an ILogger for logging purposes.
```csharp
public UnixUriScheme(ILogger logger)
```
--------------------------------
### Get Process ID
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Gets the process ID of the application running the RPC client. Discord uses this ID to monitor the application's lifecycle. Defaults to the current process ID.
```csharp
public int ProcessID { get; }
```
--------------------------------
### Register Method
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.UnixUriScheme.html
Registers the URI scheme. If a Steam ID is provided, the application will launch through Steam. Additional arguments can also be supplied.
```APIDOC
## Register(SchemeInfo)
### Description
Registers the URI scheme. If Steam ID is passed, the application will be launched through steam instead of directly. Additional arguments can be supplied if required.
### Parameters
#### Parameters
- **info** (SchemeInfo) - The register context.
### Returns
- **bool** - Returns true if the scheme was registered successfully, false otherwise.
```
--------------------------------
### Is Small Image Key External Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Assets.html
Gets a boolean value indicating if the small profile artwork is from an external link.
```csharp
[JsonIgnore]
public bool IsSmallImageKeyExternal { get; }
```
--------------------------------
### DiscordRpcClient Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Initializes a new instance of the DiscordRpcClient class with the specified application ID.
```APIDOC
## DiscordRpcClient(string)
### Description
Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join events.
### Parameters
#### Parameters
- **applicationID** (string) - The ID of the application created at discord's developers portal.
```
--------------------------------
### PipeFrame.Length
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets the length of the frame data.
```APIDOC
## Length
### Description
The length of the frame data.
### Property Value
- **uint**
```
--------------------------------
### Setting Up a Discord Party
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/joining.html
Use this snippet to define a party with a unique ID, privacy settings, and current/maximum size. This allows Discord to group users together in a shared game session.
```csharp
client.SetPresence(new()
{
Details = "Party Example",
State = "In Game",
Party = new()
{
ID = "my-unique-party-id",
Privacy = Party.PrivacySetting.Private,
Size = 1,
Max = 4,
},
});
```
--------------------------------
### PipeFrame.MessageEncoding
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets the encoding used for the pipe frames.
```APIDOC
## MessageEncoding
### Description
Gets the encoding used for the pipe frames.
### Property Value
- **Encoding**
```
--------------------------------
### Get User Avatar URL on Ready Event
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/avatars.html
Retrieve the user's avatar URL when the client is ready. This is useful for displaying user-specific information.
```csharp
client.OnReady += (sender, msg) =>
{
//Create some events so we know things are happening
Console.WriteLine("Connected to discord with user {0}", msg.User.Username);
Console.WriteLine("Avatar URL: {0}", msg.User.GetAvatarURL(User.AvatarFormat.PNG, User.AvatarSize.x128));
};
```
--------------------------------
### User Avatar Decoration Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Stores the SKU and hash for a user's avatar decoration. Use GetAvatarDecorationURL to get the URL.
```csharp
[JsonProperty("avatar_decoration_data")]
public User.AvatarDecorationData? AvatarDecoration { get; }
```
--------------------------------
### Registering a URI Scheme for Game Launch
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/joining.html
Before initializing the Discord RPC client, register a custom URI scheme for your game. This enables Discord to launch your application when users accept invites or click join buttons.
```csharp
client.RegisterUriScheme();
client.Initialize();
```
--------------------------------
### Get Avatar URL with Format and Size
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Retrieves a URL for a user's avatar, allowing specification of image format and size. Handles cases where a user has a default avatar.
```csharp
public string GetAvatarURL(User.AvatarFormat format, User.AvatarSize size)__
```
--------------------------------
### ApplicationID Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Gets the Application ID of the RPC Client.
```APIDOC
## ApplicationID
### Description
Gets the Application ID of the RPC Client.
### Property Value
string
```
--------------------------------
### IsInitialized Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Represents if the client has been Initialize()
```APIDOC
## IsInitialized
### Description
Represents if the client has been Initialize()
### Property Value
bool
```
--------------------------------
### Setting Dynamic Assets for Rich Presence
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/assets.html
This snippet demonstrates using dynamic assets by providing a URL for the image. Note that the key field has a 256-character limit, and external services may block Discord requests.
```csharp
// omitted:
// HTTP GET https://coverartarchive.org/release/6bf261f9-f18b-4ba8-92be-7afc36575f2d
client.SetPresence(new RichPresence()
{
Type = ActivityType.Listening,
Details = "Invisible",
State = "Duran Duran",
Timestamps = Timestamps.FromTimeSpan(191),
Assets = new Assets()
{
LargeImageKey = "https://coverartarchive.org/release/6bf261f9-f18b-4ba8-92be-7afc36575f2d/33192928727-500.jpg", // Links to the image
LargeImageUrl = "https://music.youtube.com/watch?v=SMCd5zrsFpE" // Links to the song when clicked
LargeImageText = "Future Past",
},
});
```
--------------------------------
### GetAvatarDecorationURL()
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets a URL to the user's avatar decoration.
```APIDOC
## GetAvatarDecorationURL()
### Description
Gets a URL to the user's avatar decoration.
### Returns
string - URL to the discord CDN for the current avatar decoration, otherwise `null`.
### Remarks
The Image will be a Animated PNG.
```
--------------------------------
### PipeFrame Opcode Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the opcode associated with this frame.
```csharp
public Opcode Opcode { readonly get; set; }
```
--------------------------------
### OnConnectionFailedEvent
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Events.html
Failed to establish any connection with discord. Discord is potentially not running?
```APIDOC
## Delegate: OnConnectionFailedEvent
### Description
Failed to establish any connection with discord. Discord is potentially not running?
### Event Signature
`delegate void OnConnectionFailedEvent(object sender, ConnectionFailedEventArgs e);`
```
--------------------------------
### ManagedNamedPipeClient.ConnectedPipe Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Gets the identifier of the pipe the client is currently connected to.
```csharp
public int ConnectedPipe { get; }
```
--------------------------------
### WindowsUriScheme Methods
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.WindowsUriScheme.html
Provides methods for interacting with Windows URI scheme registration.
```APIDOC
## GetSteamLocation()
### Description
Gets the current location of the steam client.
### Returns
string - The path to the Steam client executable.
```
```APIDOC
## Register(SchemeInfo)
### Description
Registers the URI scheme. If Steam ID is passed, the application will be launched through Steam instead of directly. Additional arguments can be supplied if required.
### Parameters
#### Parameters
- **info** (SchemeInfo) - Description: The register context.
### Returns
bool - True if the registration was successful, false otherwise.
```
--------------------------------
### Get Subscription Status
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the current subscription status to Discord events.
```csharp
public EventType Subscription { get; }
```
--------------------------------
### Initialize Discord IPC Connection
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Attempts to initialize a connection to the Discord IPC. Returns true if successful.
```csharp
public bool Initialize()
```
--------------------------------
### Add runFullTrust Capability to Package.appxmanifest
Source: https://lachee.github.io/discord-rpc-csharp/articles/getting_started/uwp.html
This XML snippet shows how to declare the 'runFullTrust' capability within the Package.appxmanifest file. This is required for WIN UI 3 applications like .NET MAUI to function correctly with the Discord RPC library.
```xml
...
```
--------------------------------
### PipeFrame.Data
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the data contained within the frame as a byte array.
```APIDOC
## Data
### Description
The data in the frame.
### Property Value
- **byte[]**
```
--------------------------------
### FileLogger Constructor with Path and LogLevel
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.FileLogger.html
Creates a new instance of the file logger, specifying the path and the log level for the logger.
```csharp
public FileLogger(string path, LogLevel level)
```
--------------------------------
### PipeFrame Length Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets the length of the frame's data in bytes.
```csharp
public uint Length { get; }
```
--------------------------------
### WindowsUriScheme Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.WindowsUriScheme.html
Initializes a new instance of the WindowsUriScheme class with a provided ILogger.
```csharp
public WindowsUriScheme(ILogger logger)
```
--------------------------------
### GetAvatarDecorationURL(AvatarFormat)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets a URL to the user's avatar decoration with a specified format.
```APIDOC
## GetAvatarDecorationURL(AvatarFormat)
### Description
Gets a URL to the user's avatar decoration with a specified format.
### Parameters
#### Path Parameters
- **format** (User.AvatarFormat) - The format of the decoration
### Returns
string - URL to the discord CDN for the current avatar decoration, otherwise `null`.
### Remarks
The avatar formats do not behave like User Avatars:
* PNG are Animated PNG
* GIF will respond with `415 Unsupported Media Type`
* WebP are not animated
* JPEG do not have transparency
Additionally, size is not support and makes no difference to the resulting image.
```
--------------------------------
### IMessage.TimeCreated Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Message.IMessage.html
Gets the time when the message was created. This property is available on all message types.
```csharp
public DateTime TimeCreated { get; }
```
--------------------------------
### UsingSteamApp Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.SchemeInfo.html
Indicates whether the URI scheme is configured to use a Steam application ID for launching.
```csharp
public bool UsingSteamApp { get; }
```
--------------------------------
### PipeFrame Data Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the raw byte array data of the frame.
```csharp
public byte[] Data { readonly get; set; }
```
--------------------------------
### MacUriScheme Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.MacUriScheme.html
Initializes a new instance of the MacUriScheme class with a specified logger.
```APIDOC
## MacUriScheme(ILogger)
### Description
Initializes a new instance of the MacUriScheme class.
### Parameters
#### Parameters
- **logger** (ILogger) - The logger instance to use for the MacUriScheme.
```
--------------------------------
### ReadyMessage
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Message.html
Indicates that the IPC is ready to send arguments.
```APIDOC
## Class: ReadyMessage
### Description
Called when the ipc is ready to send arguments.
### Type
Message
### Usage
This message signifies that the Inter-Process Communication (IPC) channel is fully initialized and ready to accept and send arguments or commands.
```
--------------------------------
### ManagedNamedPipeClient.GetPipeName (Obsolete)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Obsolete method to get the pipe name. Use PipePermutation.GetPipes instead.
```csharp
[Obsolete("Use PipePermutation.GetPipes instead", true)]
public static string GetPipeName(int pipe)
```
--------------------------------
### Configuration Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
The current configuration the connection is using. Only becomes available after a ready event.
```APIDOC
## Configuration
### Description
The current configuration the connection is using. Only becomes available after a ready event.
### Property Value
Configuration
```
--------------------------------
### SteamID Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Gets the Steam ID of the RPC Client. This value can be null if none was supplied.
```APIDOC
## SteamID
### Description
Gets the Steam ID of the RPC Client. This value can be null if none was supplied.
### Property Value
string
```
--------------------------------
### ManagedNamedPipeClient.IsUnix (Obsolete)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Obsolete method to check if the current platform is Unix-based. Use PipePermutation.GetPipes instead.
```csharp
[Obsolete("Use PipePermutation.GetPipes instead", true)]
public static bool IsUnix()
```
--------------------------------
### DiscordRpcClient Constructor with Advanced Options
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Creates a new Discord RPC Client with advanced configuration options. This constructor is useful for custom logging, pipe selection, and event handling.
```csharp
public DiscordRpcClient(string applicationID, int pipe = -1, ILogger logger = null, bool autoEvents = true, INamedPipeClient client = null)
```
--------------------------------
### CurrentPresence Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
The current presence that the client has. Gets set with SetPresence(RichPresence) and updated on OnPresenceUpdate.
```APIDOC
## CurrentPresence
### Description
The current presence that the client has. Gets set with SetPresence(RichPresence) and updated on OnPresenceUpdate.
### Property Value
RichPresence
```
--------------------------------
### ConsoleLogger Constructor (With LogLevel and Color)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Creates a new instance of a Console Logger with a specified log level and coloring option.
```csharp
public ConsoleLogger(LogLevel level, bool coloured)
```
--------------------------------
### Check Initialization State
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Represents whether the client has been successfully initialized using the Initialize() method. An uninitialized client cannot establish a connection.
```csharp
public bool IsInitialized { get; }
```
--------------------------------
### PipeFrame MessageEncoding Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets the character encoding used for converting the frame data to and from strings.
```csharp
public Encoding MessageEncoding { get; }
```
--------------------------------
### FileLogger Constructor with Path
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.FileLogger.html
Creates a new instance of the file logger, specifying the path for the log file.
```csharp
public FileLogger(string path)
```
--------------------------------
### PipeFrame Message Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Gets or sets the frame's data as a string, using the MessageEncoding.
```csharp
public string Message { get; set; }
```
--------------------------------
### ConsoleLogger Coloured Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Gets or sets a boolean value indicating whether the output should be colored.
```csharp
public bool Coloured { get; set; }
```
--------------------------------
### DiscordRpcClient Constructor with Application ID
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Creates a new Discord RPC Client. Use this constructor when you only need to provide your application's ID.
```csharp
public DiscordRpcClient(string applicationID)
```
--------------------------------
### MacUriScheme Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.MacUriScheme.html
Initializes a new instance of the MacUriScheme class, requiring an ILogger for logging purposes.
```csharp
public MacUriScheme(ILogger logger)
```
--------------------------------
### ManagedNamedPipeClient.Logger Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Sets or gets the ILogger instance used by the pipe client for logging purposes.
```csharp
public ILogger Logger { get; set; }
```
--------------------------------
### Configuration Class Definition
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Configuration.html
Defines the base structure for the Discord RPC configuration.
```csharp
public class Configuration__
```
--------------------------------
### Register Method Signature
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.IRegisterUriScheme.html
Registers a URI scheme. This method can optionally launch the application through Steam if a Steam ID is provided in the SchemeInfo. Additional arguments can also be supplied.
```csharp
bool Register(SchemeInfo info)
```
--------------------------------
### Logger Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.INamedPipeClient.html
Gets or sets the logger instance used by the pipe client for logging purposes.
```csharp
ILogger Logger { get; set; }
```
--------------------------------
### Configuration Class
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Configuration.html
The Configuration class holds settings for establishing a Discord Rich Presence connection. It includes properties to specify the API endpoint, CDN host, and the connection environment.
```APIDOC
## Class Configuration
Namespace: DiscordRPC
Assembly: DiscordRPC.dll
Configuration of the current RPC connection.
```csharp
public class Configuration
```
### Properties
#### ApiEndpoint
The Discord API endpoint that should be used.
```csharp
[JsonProperty("api_endpoint")]
public string ApiEndpoint { get; set; }
```
- **Type**: string
#### CdnHost
The CDN endpoint.
```csharp
[JsonProperty("cdn_host")]
public string CdnHost { get; set; }
```
- **Type**: string
#### Environment
The type of environment the connection on. Usually Production.
```csharp
[JsonProperty("environment")]
public string Environment { get; set; }
```
- **Type**: string
```
--------------------------------
### Clear Rich Presence Timestamps
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start and end time of CurrentPresence to null and sends it to Discord.
```csharp
public RichPresence UpdateClearTime()__
```
--------------------------------
### Respond to Join Request (User)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Responds to a Join Request for a specific user. Requests have a 30-second timeout. It's recommended to call Invoke() faster than every 15 seconds.
```csharp
public void Respond(User user, bool acceptRequest)
```
--------------------------------
### UpdateClearTime
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Sets the start and end time of CurrentPresence to null and sends it to Discord. Returns the updated Rich Presence.
```APIDOC
## UpdateClearTime()
### Description
Sets the start and end time of CurrentPresence to null and sends it to Discord. Returns the updated Rich Presence.
### Method
`public RichPresence UpdateClearTime()`
### Returns
#### Success Response
- **RichPresence** (RichPresence) - Updated Rich Presence
```
--------------------------------
### FromTimeSpan Method (TimeSpan)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Creates a new timestamp starting at the current time and ending after a specified TimeSpan duration.
```csharp
public static Timestamps FromTimeSpan(TimeSpan timespan)
```
--------------------------------
### ManagedNamedPipeClient Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Creates a new instance of the ManagedNamedPipeClient. This constructor initializes the client but does not establish a connection.
```csharp
public ManagedNamedPipeClient()
```
--------------------------------
### FromTimeSpan Method (double)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Creates a new timestamp starting at the current time and ending after a specified duration in seconds.
```csharp
public static Timestamps FromTimeSpan(double seconds)
```
--------------------------------
### GetAvatarURL()
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets a URL to the user's avatar PNG. If the user does not have an avatar, a URL to a default avatar is returned.
```APIDOC
## GetAvatarURL()
### Description
Gets a URL to the user's avatar PNG. If the user does not have an avatar, a URL to a default avatar is returned.
### Returns
string - URL to the discord CDN for the particular avatar
### Remarks
The file returned will be `128x128px`.
```
--------------------------------
### ConsoleLogger Constructor (Default)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Creates a new instance of a Console Logger with default settings.
```csharp
public ConsoleLogger()
```
--------------------------------
### End Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Gets or sets the time the match will end. When set, displays 'remaining' time in the rich presence.
```csharp
[JsonIgnore]
public DateTime? End { get; set; }
```
--------------------------------
### Set Rich Presence Details
Source: https://lachee.github.io/discord-rpc-csharp/articles/getting_started/introduction.html
Set the presence information, including details, state, and assets like images, after the client has been initialized. Duplicate calls are handled by the library and Discord.
```csharp
//Set Presence
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"
}
});
```
--------------------------------
### ConsoleLogger Level Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Gets or sets the log level to apply to this logger. Only messages with this level or higher will be logged.
```csharp
public LogLevel Level { get; set; }
```
--------------------------------
### UnixUriScheme
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.html
Registers a URI scheme on Unix-like systems using the xdg-open command. The scheme is saved as a .desktop file in the user's local applications directory.
```APIDOC
## UnixUriScheme
### Description
Registers a URI scheme on Unix-like systems.
### Usage
This class utilizes the `xdg-open` command to register a URI scheme by creating a `.desktop` file in the user's local applications directory.
### Methods
(Specific methods not detailed in source, but assume registration functionality)
### Parameters
(Specific parameters not detailed in source)
### Response
(Specific response details not detailed in source)
```
--------------------------------
### ManagedNamedPipeClient.GetPipeName with Sandbox (Obsolete)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Obsolete method to get the pipe name for a specific sandbox. Use PipePermutation.GetPipes instead.
```csharp
[Obsolete("Use PipePermutation.GetPipes instead", true)]
public static string GetPipeName(int pipe, string sandbox)
```
--------------------------------
### IRegisterUriScheme.Register
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.IRegisterUriScheme.html
Registers a URI scheme for the application. This allows the application to be launched via a custom URI. If a Steam ID is provided, the application will launch through Steam.
```APIDOC
## Register(SchemeInfo)
### Description
Registers the URI scheme. If Steam ID is passed, the application will be launched through steam instead of directly. Additional arguments can be supplied if required.
### Method
Register
### Parameters
#### Path Parameters
- **info** (SchemeInfo) - Required - The register context.
### Returns
#### Success Response
- **bool** - Indicates whether the registration was successful.
```
--------------------------------
### ExecutablePath Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.SchemeInfo.html
Specifies the file path to the executable that will be launched when the URI scheme is invoked.
```csharp
public string ExecutablePath { readonly get; set; }
```
--------------------------------
### ToString
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Formats the user object into a string suitable for display, prioritizing the display name, then username and discriminator.
```APIDOC
## ToString()
### Description
Formats the user into a displayable format. If the user has a DisplayName, then this will be used. If the user still has a discriminator, then this will return the form of `Username#Discriminator`.
### Method
```
public override string ToString()
```
### Returns
* **string** - String of the user that can be used for display.
```
--------------------------------
### ConsoleLogger Colored Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Gets or sets a boolean value indicating whether the output should be colored. This is an alias for the Coloured property.
```csharp
public bool Colored { get; set; }
```
--------------------------------
### Is Large Image Key External Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Assets.html
Gets a boolean value indicating if the large square image is from an external link.
```csharp
[JsonIgnore]
public bool IsLargeImageKeyExternal { get; }
```
--------------------------------
### ManagedNamedPipeClient.Connect Method
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Attempts to connect the client to a specified named pipe. Returns true if the connection is successful, false otherwise.
```csharp
public bool Connect(int pipe)
```
--------------------------------
### Timestamps Properties
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Details the properties of the Timestamps class, including End, EndUnixMilliseconds, Now, Start, and StartUnixMilliseconds, which represent and convert time values.
```APIDOC
## Properties
### End
The time the match will end. When included (not-null), the time in the rich presence will be shown as "00:01 remaining". This will override the "elapsed" to "remaining".
```csharp
[JsonIgnore]
public DateTime? End { get; set; }
```
#### Property Value
DateTime?
### EndUnixMilliseconds
Converts between DateTime and Milliseconds to give the Unix Epoch Time for the End.
```csharp
[JsonProperty("end", NullValueHandling = NullValueHandling.Ignore)]
public ulong? EndUnixMilliseconds { get; set; }
```
#### Property Value
ulong?
### Now
A new timestamp that starts from the current time.
```csharp
public static Timestamps Now { get; }
```
#### Property Value
Timestamps
### Start
The time that match started. When included (not-null), the time in the rich presence will be shown as "00:01 elapsed".
```csharp
[JsonIgnore]
public DateTime? Start { get; set; }
```
#### Property Value
DateTime?
### StartUnixMilliseconds
Converts between DateTime and Milliseconds to give the Unix Epoch Time for the Start.
```csharp
[JsonProperty("start", NullValueHandling = NullValueHandling.Ignore)]
public ulong? StartUnixMilliseconds { get; set; }
```
#### Property Value
ulong?
```
--------------------------------
### Register URI Scheme
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.WindowsUriScheme.html
Registers a custom URI scheme on Windows. If a Steam ID is provided in SchemeInfo, the application will launch via Steam. Additional arguments can be supplied as needed.
```csharp
public bool Register(SchemeInfo info)
```
--------------------------------
### GetAvatarURL(AvatarFormat)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
Gets a URL to the user's avatar with the specified format. If the user does not have an avatar, a URL to a default avatar is returned.
```APIDOC
## GetAvatarURL(AvatarFormat)
### Description
Gets a URL to the user's avatar with the specified format. If the user does not have an avatar, a URL to a default avatar is returned.
### Parameters
#### Path Parameters
- **format** (User.AvatarFormat) - The format of the target avatar
### Returns
string - URL to the discord CDN for the particular avatar
### Remarks
The file returned will be `128x128px`.
The default avatar only supports the PNG format.
### Exceptions
#### BadImageFormatException
The user has a default avatar but a format other than PNG is requested.
```
--------------------------------
### ConsoleLogger Constructor (With LogLevel)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.ConsoleLogger.html
Creates a new instance of a Console Logger with a specified log level.
```csharp
public ConsoleLogger(LogLevel level)
```
--------------------------------
### SteamAppID Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.SchemeInfo.html
Optional Steam application ID. If provided, the application will launch through Steam. Can be null if not using Steam.
```csharp
public string SteamAppID { readonly get; set; }
```
--------------------------------
### Get Current User
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the currently connected Discord user. This property is updated with the ready event and will be null until the event is fired.
```csharp
public User CurrentUser { get; }
```
--------------------------------
### Respond to Join Request (ulong)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Responds to a Join Request for a specific user ID. Requests have a 30-second timeout. It's recommended to call Invoke() faster than every 15 seconds.
```csharp
public void Respond(ulong userID, bool acceptRequest)
```
--------------------------------
### BaseRichPresence Helper Methods
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.BaseRichPresence.html
Methods to check if the Rich Presence contains valid assets, party information, secrets, or timestamps.
```csharp
public bool HasAssets()
```
```csharp
public bool HasParty()
```
```csharp
public bool HasSecrets()
```
```csharp
public bool HasTimestamps()
```
--------------------------------
### OnErrorEvent
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Events.html
Called when an error has occurred during the transmission of a message. For example, if a bad Rich Presence payload is sent, this event will be called explaining what went wrong.
```APIDOC
## Delegate: OnErrorEvent
### Description
Called when an error has occurred during the transmission of a message. For example, if a bad Rich Presence payload is sent, this event will be called explaining what went wrong.
### Event Signature
`delegate void OnErrorEvent(object sender, ErrorEventArgs e);`
```
--------------------------------
### Register URI Scheme
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Registers the application executable to a custom URI scheme, which is required for the Join feature. Discord uses this to launch your application when a user accepts a join request.
```csharp
public bool RegisterUriScheme(string steamAppID = null, string executable = null)
```
--------------------------------
### Get Steam ID
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the Steam ID associated with the RPC client, if one was provided during initialization. This property can be null if no Steam ID was supplied.
```csharp
public string SteamID { get; }
```
--------------------------------
### Get Avatar Decoration URL
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/avatars.html
Retrieve the URL for an avatar decoration. Returns null if no decoration is available. Decorations are typically animated using APNG.
```csharp
string decorationUrl = client.CurrentUser.GetAvatarDecorationURL();
if (decorationUrl != null) {
DownloadDecoration(decorationUrl);
}
```
--------------------------------
### WindowsUriScheme
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Registry.html
Registers a URI scheme on Windows. This allows Discord to launch your application when a URI with the registered scheme is encountered.
```APIDOC
## WindowsUriScheme
### Description
Registers a URI scheme on Windows.
### Usage
This class provides methods to associate a custom URI scheme with your application on Windows.
### Methods
(Specific methods not detailed in source, but assume registration functionality)
### Parameters
(Specific parameters not detailed in source)
### Response
(Specific response details not detailed in source)
```
--------------------------------
### IMessage.Type Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Message.IMessage.html
Gets the type of message received from Discord. This is an abstract property that must be implemented by derived classes to specify the message's category.
```csharp
public abstract MessageType Type { get; }
```
--------------------------------
### Update Rich Presence Small Asset
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Updates the small Assets of the CurrentPresence and sends the updated presence to Discord. Both `key` and `tooltip` are optional and will be ignored if null.
```csharp
public RichPresence UpdateSmallAsset(string key = null, string tooltip = null)__
```
--------------------------------
### Get Target Pipe
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the target pipe for the Discord client connection. Use -1 to scan all pipes. Useful for testing multiple Discord clients.
```csharp
public int TargetPipe { get; }
```
--------------------------------
### Registering a Steam URI Scheme
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/joining.html
For Steam games, you can register the 'steam://' scheme by providing your game's App ID. This allows Discord to launch your Steam game through the provided scheme.
```csharp
client.RegisterUriScheme("657300");
client.Initialize();
```
--------------------------------
### Add Discord RPC C# Package
Source: https://lachee.github.io/discord-rpc-csharp/index.html
Use this command to add the DiscordRichPresence NuGet package to your project.
```bash
dotnet add package DiscordRichPresence
```
--------------------------------
### Get Maximum Queue Size
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the maximum size allowed for the message queue that receives messages from Discord. This limits the number of pending events or updates.
```csharp
public int MaxQueueSize { get; }
```
--------------------------------
### Get Current Presence
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Retrieves the Rich Presence currently set for the client. This value is updated when SetPresence is called and also upon receiving an OnPresenceUpdate event.
```csharp
public RichPresence CurrentPresence { get; }
```
--------------------------------
### PipeFrame Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Creates a new PipeFrame instance with a specified opcode and data.
```APIDOC
## PipeFrame(Opcode, object)
### Description
Creates a new pipe frame instance.
### Parameters
#### Parameters
- **opcode** (Opcode) - The opcode of the frame.
- **data** (object) - The data of the frame that will be serialized as JSON.
```
--------------------------------
### Timestamps Methods
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Timestamps.html
Explains the static methods available for the Timestamps class, including FromTimeSpan, FromUnixMilliseconds, and ToUnixMilliseconds, for creating and converting time values.
```APIDOC
## Methods
### FromTimeSpan(double seconds)
Creates a new timestamp starting at the current time and ending in the supplied timespan.
```csharp
public static Timestamps FromTimeSpan(double seconds)
```
#### Parameters
`seconds` double
How long the Timestamp will last for in seconds.
#### Returns
Timestamps
Returns a new timestamp with given duration.
### FromTimeSpan(TimeSpan timespan)
Creates a new timestamp starting at current time and ending in the supplied timespan.
```csharp
public static Timestamps FromTimeSpan(TimeSpan timespan)
```
#### Parameters
`timespan` TimeSpan
How long the Timestamp will last for.
#### Returns
Timestamps
Returns a new timestamp with given duration.
### FromUnixMilliseconds(ulong unixTime)
Converts a Unix Epoch time into a DateTime.
```csharp
public static DateTime FromUnixMilliseconds(ulong unixTime)
```
#### Parameters
`unixTime` ulong
The time in milliseconds since 1970 / 01 / 01
#### Returns
DateTime
### ToUnixMilliseconds(DateTime date)
Converts a DateTime into a Unix Epoch time (in milliseconds).
```csharp
public static ulong ToUnixMilliseconds(DateTime date)
```
#### Parameters
`date` DateTime
The datetime to convert
#### Returns
ulong
```
--------------------------------
### ProcessID Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Gets the ID of the process used to run the RPC Client. Discord tracks this process ID and waits for its termination. Defaults to the current application process ID.
```APIDOC
## ProcessID
### Description
Gets the ID of the process used to run the RPC Client. Discord tracks this process ID and waits for its termination. Defaults to the current application process ID.
### Property Value
int
```
--------------------------------
### PipeFrame Constructor
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeFrame.html
Creates a new PipeFrame instance with a specified opcode and data.
```csharp
public PipeFrame(Opcode opcode, object data)
```
--------------------------------
### HasRegisteredUriScheme Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Gets a value indicating if the client has registered a URI Scheme. If this is false, Join events will fail. To register a URI Scheme, call RegisterUriScheme(string, string).
```APIDOC
## HasRegisteredUriScheme
### Description
Gets a value indicating if the client has registered a URI Scheme. If this is false, Join events will fail. To register a URI Scheme, call RegisterUriScheme(string, string).
### Property Value
bool
```
--------------------------------
### OnConnectionEstablishedEvent
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Events.html
The connection to the discord client was successful. This is called before OnReadyEvent.
```APIDOC
## Delegate: OnConnectionEstablishedEvent
### Description
The connection to the discord client was successful. This is called before OnReadyEvent.
### Event Signature
`delegate void OnConnectionEstablishedEvent(object sender, EventArgs e);`
```
--------------------------------
### ManagedNamedPipeClient Constructors
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.ManagedNamedPipeClient.html
Creates a new instance of a Managed NamedPipe client. This constructor sets up the client but does not connect to any pipe.
```APIDOC
## ManagedNamedPipeClient()
### Description
Creates a new instance of a Managed NamedPipe client. Doesn't connect to anything yet, just setups the values.
### Method
Constructor
### Parameters
None
```
--------------------------------
### Get Animated Avatar URL
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/avatars.html
Retrieve the URL for an animated avatar if available, otherwise fall back to a PNG format. Note that Discord limits animated avatars to GIF or WebP.
```csharp
string url;
if (client.CurrentUser.IsAvatarAnimated)
{
url = client.CurrentUser.GetAvatarURL(User.AvatarFormat.GIF, User.AvatarSize.x64);
}
else
{
url = client.CurrentUser.GetAvatarURL(User.AvatarFormat.PNG, User.AvatarSize.x64);
}
```
--------------------------------
### Respond to Join Request (JoinRequestMessage)
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.DiscordRpcClient.html
Responds to a Join Request with the provided JoinRequestMessage. Requests have a 30-second timeout. It's recommended to call Invoke() faster than every 15 seconds.
```csharp
public void Respond(JoinRequestMessage request, bool acceptRequest)
```
--------------------------------
### User Username Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.User.html
The username of the player.
```csharp
[JsonProperty("username")]
public string Username { get; }
```
--------------------------------
### Configuration Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Message.ReadyMessage.html
The Configuration property holds the connection configuration details. It is marked with JsonProperty to indicate its mapping in JSON.
```csharp
[JsonProperty("config")]
public Configuration Configuration { get; set; }__
```
--------------------------------
### GetPipes
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.IO.PipeLocation.html
Generates a sequence of pipe names that Discord can use for the IPC for the current operating system. The names are ordered and will check multiple locations for a suitable pipe. For Unix systems, multiple TEMP directories are checked and multiple package managers are considered. This means that there is not a 1 to 1 mapping of pipe names to indices, as there are many locations for a single pipe index.
```APIDOC
## GetPipes(int)
### Description
Generates a sequence of pipe names that Discord can use for the IPC for the current operating system.
### Method
public static IEnumerable GetPipes(int startPipe = 0)
### Parameters
#### Path Parameters
- **startPipe** (int) - Optional - The starting index for the pipe names.
### Returns
#### Success Response
- IEnumerable - An enumerable collection of pipe names.
### Remarks
The names are ordered and will check multiple locations for a suitable pipe. For Unix systems, multiple TEMP directories are checked and multiple package managers are considered. This means that there is not a 1 to 1 mapping of pipe names to indices, as there are many locations for a single pipe index.
```
--------------------------------
### Small Image Text Property
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Assets.html
Sets the tooltip displayed when hovering over the small circle image in the activity card. Maximum 128 characters.
```csharp
[JsonProperty("small_text", NullValueHandling = NullValueHandling.Ignore)]
public string SmallImageText { get; set; }__
```
--------------------------------
### Handle Join Requests in Discord RPC C#
Source: https://lachee.github.io/discord-rpc-csharp/articles/features/joining.html
Subscribe to join requests and respond in-game. This requires setting privacy to 'Private' in Discord and listening for the OnJoinRequested event.
```csharp
client.Subscribe(EventType.JoinRequest);
client.OnJoinRequested += async (object sender, JoinRequestMessage args) => {
var result = await UI.ShowRequestToJoin(args.user); // Hypothetical UI system
client.Respond(args.User, result.accepted);
};
```
--------------------------------
### FileLogger Constructors
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.FileLogger.html
Provides constructors for creating instances of the FileLogger class.
```APIDOC
## FileLogger(string)
### Description
Creates a new instance of the file logger.
### Parameters
#### path
- **path** (string) - The path of the log file.
## FileLogger(string, LogLevel)
### Description
Creates a new instance of the file logger.
### Parameters
#### path
- **path** (string) - The path of the log file.
#### level
- **level** (LogLevel) - The level to assign to the logger.
```
--------------------------------
### Trace Method
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.Logging.NullLogger.html
Informative log messages.
```APIDOC
### Trace(string, params object[])
Informative log messages
```
public void Trace(string message, params object[] args)
```
#### Parameters
`message` string
`args` object[]
```
--------------------------------
### Set RichPresence Assets
Source: https://lachee.github.io/discord-rpc-csharp/api/DiscordRPC.RichPresence.html
Configures the assets (images and tooltips) for the Rich Presence. This method is used to associate visual elements with the activity.
```csharp
public RichPresence WithAssets(Assets assets)
```