Skip to content

Commit

Permalink
fix: fix vesktop not being detected (Closes #188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Azn9 committed Oct 5, 2024
1 parent 3c28088 commit 6ab299b
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ class DiagnoseService : DisposableCoroutineScope {
)

val discord = arrayOf(
// Official clients
"Discord.exe",
"DiscordPTB.exe",
"DiscordCanary.exe",
"DiscordDevelopment.exe"
"DiscordDevelopment.exe",

// Custom clients
"Vesktop.exe"
)

val ipcFile = (0..9).map { "discord-ipc-$it" }
Expand Down Expand Up @@ -138,25 +142,23 @@ class DiagnoseService : DisposableCoroutineScope {
}

val process = Runtime.getRuntime().exec("""tasklist /V /fi "SESSIONNAME eq Console"""")
val lines = process.inputStream.bufferedReader(StandardCharsets.UTF_8).use { reader ->
reader.lineSequence().filter { line -> line.contains("Discord", true) }.toList()
val allLines = process.inputStream.bufferedReader(StandardCharsets.UTF_8).use { reader ->
reader.lineSequence().toList()
}

if (lines.isEmpty()) {
return Discord.CLOSED
} else {
val discordClientNotRunning = lines.none { line -> discord.any { exe -> line.startsWith(exe, true) } }
if (discordClientNotRunning) {
val discordBrowser = lines.any { line ->
line.contains("discord", true) && browsers.any { browser -> line.startsWith(browser, true) }
}
if (discordBrowser) {
return Discord.BROWSER
}
val discordClientNotRunning = allLines.none { line -> discord.any { exe -> line.startsWith(exe, true) } }
if (discordClientNotRunning) {
val discordBrowser = allLines.any { line ->
browsers.any { browser -> line.startsWith(browser, true) }
}
if (discordBrowser) {
return Discord.BROWSER
}
} else {
return Discord.RUNNING_WITHOUT_RICH_PRESENCE_ENABLED
}

return Discord.RUNNING_WITHOUT_RICH_PRESENCE_ENABLED
return Discord.CLOSED
}

private fun readPlugins(): Plugins {
Expand Down

0 comments on commit 6ab299b

Please sign in to comment.