GooseMod / OpenAsar

Open-source alternative of Discord desktop's app.asar
https://openasar.dev
GNU Affero General Public License v3.0
2.54k stars 67 forks source link

[Enhancement] Autoamticly find latest version of discord in .bat #161

Closed BourbonCrow closed 11 months ago

BourbonCrow commented 11 months ago

Here are 2 examples they both seem to work fine 2nd example looks way more clean tho, no idea if this is any helpful but maybe it would be esier to check for latest version folder instead of updating the batchfile and manually updating the number when discord updates, this code i guess would only need to be updated if they change how they write the versions this works with app-x.x.x

::Example 1

@echo off
setlocal enabledelayedexpansion
set newest=000000000
PUSHD %localappdata%\Discord\
for /f "delims=" %%G in ('dir /b /ad ^| findstr /r "^app-[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do (
    FOR /F "tokens=1-3 delims=." %%H IN ("%%~G") DO (
        SET "node1=000%%H"
        SET "node1=!node1:~-3!"
        SET "node2=000%%I"
        SET "node2=!node2:~-3!"
        SET "node3=000%%J"
        SET "node3=!node3:~-3!"
        IF 1!node1!!node2!!node3! GTR 1!newest! (
            set newest=!node1!!node2!!node3!
            set LatestVersion=%%G
        )
    )
)
echo %LatestVersion%
POPD
pause

::Example 2

@echo off

SET Remote="%localappdata%\Discord\"
SET %LatestVersion%=not set

for /f %%a in ('dir %Remote% /b /on  ^| findstr /r "^app-[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do (SET %LatestVersion%=%%a)

echo %LatestVersion%
pause

image

BourbonCrow commented 11 months ago

should prolly mention as well that 2.0.1 version ofc doesnt exist i just made a lot of random test folders to make sure it worked incase ppl wonder :P

CanadaHonk commented 11 months ago

Many people (including me) have done this before, but it works worse in production regardless. The versions are already semi automatically updated now. Sorry.