Skip to content

Commit 9af25ae

Browse files
committed
Add idle status
1 parent 8668c40 commit 9af25ae

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Program.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static void OnUpdate()
9494
{
9595
process = Process.GetProcesses().Where(x => x.ProcessName.StartsWith("DOSBox")).ToList()[0];
9696
}
97-
catch(IndexOutOfRangeException) { return; }
97+
catch(Exception) { return; }
9898

9999
if(process.MainWindowTitle != windowTitle)
100100
{
@@ -114,16 +114,27 @@ private static void SetNewPresence()
114114
i--;
115115
}
116116
}
117+
118+
string details;
119+
try
120+
{
121+
if (Regex.Split(titleParts[3], "\\s+")[1] == "DOSBOX")
122+
details = "Idling in the Command Line";
123+
else
124+
details = Regex.Split(titleParts[3], "\\s+")[1];
125+
}
126+
catch(Exception) { return; }
127+
117128
string status;
118129
try
119130
{
120131
status = new StringBuilder($"v{titleParts[0].Split(' ')[1]}").AppendFormat(", {0}, {1}", titleParts[1], titleParts[2]).ToString();
121132
}
122-
catch(IndexOutOfRangeException) { return; }
133+
catch(Exception) { return; }
123134

124135
client.SetPresence(new RichPresence
125136
{
126-
Details = Regex.Split(titleParts[3], "\\s+")[1],
137+
Details = details,
127138
State = status,
128139
Timestamps = new Timestamps(DateTime.UtcNow),
129140
Assets = new Assets()

0 commit comments

Comments
 (0)