0% 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.

Uploaded by

reflex4263
Copyright
© © All Rights Reserved
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% 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.

Uploaded by

reflex4263
Copyright
© © All Rights Reserved
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();

// Set up buttons with appropriate URLs


DiscordRPC.Button[] buttons = {
new DiscordRPC.Button() { Label = "Free Panel", Url =
"https://discord.gg/2hKy4EkQJJ" },
new DiscordRPC.Button() { Label = "WhatsApp", Url =
"https://wa.me//212666666597" }
};

// Set up the initial presence


presence = new RichPresence()
{
Buttons = buttons,
Timestamps = rpctimestamp,

Assets = new Assets()


{
LargeImageKey = "https://i.postimg.cc/4NbMRF2j/logo1bv-
animation.gif",
LargeImageText = "Bou7ssini",
SmallImageKey =
"https://media4.giphy.com/media/xmOMPI63SsyZyKz2Tx/giphy.gif?
cid=790b7611485d6e9b471bcd8f93609e96f8a02c35a7e05685&rid=giphy.gif&ct=s",
SmallImageText = ""
}
};

client.SetPresence(presence);
UpdateDiscordPresence();
}

public static void SetState(string state, bool watching = false)


{
if (watching)
state = "Looking at " + state;

presence.State = state;
client.SetPresence(presence);
}

private static void UpdateDiscordPresence()


{
// 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 = "";
}

client.SetPresence(presence);
}

private static DateTime UnixTimeToDateTime(long unixTime)


{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0,
DateTimeKind.Utc);
return unixStart.AddSeconds(unixTime).ToLocalTime();
}
=================================
RPC.rpctimestamp = Timestamps.Now;
RPC.InitializeRPC();
==================
lik : https://discord.com/developers/applications

You might also like