The document outlines a C# implementation for integrating Discord Rich Presence into an application using the DiscordRpcClient. It includes methods for initializing the RPC, setting the user's presence with buttons and timestamps, and updating the presence based on user data. The code also provides functionality to convert Unix time to a DateTime format for displaying subscription expiry dates.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
36 views2 pages
Message
The document outlines a C# implementation for integrating Discord Rich Presence into an application using the DiscordRpcClient. It includes methods for initializing the RPC, setting the user's presence with buttons and timestamps, and updating the presence based on user data. The code also provides functionality to convert Unix time to a DateTime format for displaying subscription expiry dates.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
public static DiscordRpcClient client;
public static Timestamps rpctimestamp { get; set; }
private static RichPresence presence;
public static void InitializeRPC()
{ // Replace "YOUR_DISCORD_APP_ID_HERE" with your actual Discord application ID client = new DiscordRpcClient("1204918771567820831"); client.Initialize();
{ // Check if the user is logged in before accessing the username and expiry date if (LOGIN.KeyAuthApp.user_data != null) { string username = LOGIN.KeyAuthApp.user_data.username; DateTime expiryDateTime = UnixTimeToDateTime(long.Parse(LOGIN.KeyAuthApp.user_data.subscriptions[0].expiry)); presence.Details = $"User: {username}"; presence.State = $"Expiry Date: {expiryDateTime:yyyy-MM-dd HH:mm}"; } else { presence.Details = "USER"; presence.State = ""; }