diff --git a/CustomRPC/MainForm.cs b/CustomRPC/MainForm.cs
index 3ccd0d12..f2a10788 100644
--- a/CustomRPC/MainForm.cs
+++ b/CustomRPC/MainForm.cs
@@ -778,10 +778,12 @@ private bool SetPresence()
settings.button1URL = settings.button1URL.Trim();
settings.button2URL = settings.button2URL.Trim();
+ string settingsWithCountdown = Countdownify(settings.details);
+
var rp = new RichPresence()
{
Type = (ActivityType)settings.type,
- Details = settings.details,
+ Details = settingsWithCountdown,
State = settings.state,
Party = new Party()
{
@@ -817,7 +819,8 @@ string Proxify(string key)
return Regex.Replace(key, @"//((cdn)|(media))\.discordapp\.((com)|(net))/", "//customrp.xyz/proxy/");
return key;
- };
+ }
+ ;
try
{
@@ -1705,5 +1708,36 @@ private void Update(object sender, EventArgs e)
Utils.SaveSettings();
SetPresence();
}
+
+ ///
+ /// Replace {countdown: dd/mm/yyyy} with number of days until that day
+ ///
+ ///
+ ///
+ private string Countdownify(string input)
+ {
+ string[] split = input.Split('{', '}');
+ string output = "";
+
+ foreach (var s in split)
+ {
+ if (s.StartsWith("countdown: ") && s.Length == 21)
+ {
+ string date = s.Substring(11, 10);
+
+ DateTime dateTime = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
+ int daysUntilDate = dateTime.Subtract(DateTime.Now).Days;
+ int daysLeft = Math.Max(daysUntilDate, 0); // If we pass the day we don't want to go negative
+
+ output += daysLeft;
+ }
+ else
+ {
+ output += s;
+ }
+ }
+
+ return output;
+ }
}
}
\ No newline at end of file