Добавить очистку кэша Discord PTB в service.bat (#15962)

This commit is contained in:
0x0Bug
2026-07-22 07:09:56 +02:00
committed by GitHub
parent c3b30cd233
commit 9c3817d40a

View File

@@ -678,37 +678,22 @@ if !found_any_conflict!==1 (
:: Discord cache clearing :: Discord cache clearing
set "CHOICE=" set "CHOICE="
set /p "CHOICE=Do you want to clear the Discord cache? (Y/N) (default: Y) " set /p "CHOICE=Do you want to clear the Discord and Discord PTB cache? (Y/N) (default: Y) "
if "!CHOICE!"=="" set "CHOICE=Y" if "!CHOICE!"=="" set "CHOICE=Y"
if "!CHOICE!"=="y" set "CHOICE=Y" if "!CHOICE!"=="y" set "CHOICE=Y"
if /i "!CHOICE!"=="Y" ( if /i "!CHOICE!"=="Y" (
tasklist /FI "IMAGENAME eq Discord.exe" | findstr /I "Discord.exe" > nul set "discordFound=0"
if !errorlevel!==0 ( if exist "%APPDATA%\discord\" (
echo Discord is running, closing... set "discordFound=1"
taskkill /IM Discord.exe /F > nul call :clear_discord_cache "Discord.exe" "Discord" "%APPDATA%\discord"
if !errorlevel! == 0 (
call :PrintGreen "Discord was successfully closed"
) else (
call :PrintRed "Unable to close Discord"
)
) )
if exist "%APPDATA%\discordptb\" (
set "discordCacheDir=%appdata%\discord" set "discordFound=1"
call :clear_discord_cache "DiscordPTB.exe" "Discord PTB" "%APPDATA%\discordptb"
for %%d in ("Cache" "Code Cache" "GPUCache") do (
set "dirPath=!discordCacheDir!\%%~d"
if exist "!dirPath!" (
rd /s /q "!dirPath!"
if !errorlevel!==0 (
call :PrintGreen "Successfully deleted !dirPath!"
) else (
call :PrintRed "Failed to delete !dirPath!"
)
) else (
call :PrintRed "!dirPath! does not exist"
)
) )
if !discordFound! equ 0 call :PrintRed "Discord and Discord PTB were not found"
set "discordFound="
) )
echo: echo:
@@ -1133,6 +1118,42 @@ exit /b
:: Utility functions :: Utility functions
:clear_discord_cache
setlocal EnableDelayedExpansion
set "discordProcess=%~1"
set "discordName=%~2"
set "discordCacheDir=%~3"
tasklist /FI "IMAGENAME eq !discordProcess!" 2>nul | findstr /I /C:"!discordProcess!" >nul
if !errorlevel! equ 0 (
echo !discordName! is running, closing...
taskkill /IM "!discordProcess!" /F >nul 2>&1
if !errorlevel! equ 0 (
call :PrintGreen "!discordName! was successfully closed"
) else (
call :PrintRed "Unable to close !discordName!"
)
)
if exist "!discordCacheDir!\" (
for %%d in ("Cache" "Code Cache" "GPUCache") do (
set "dirPath=!discordCacheDir!\%%~d"
if exist "!dirPath!\" (
rd /s /q "!dirPath!" >nul 2>&1
if exist "!dirPath!\" (
call :PrintRed "Failed to delete !dirPath!"
) else (
call :PrintGreen "Successfully deleted !dirPath!"
)
) else (
call :PrintRed "!dirPath! does not exist"
)
)
)
endlocal
exit /b
:PrintGreen :PrintGreen
powershell -NoProfile -Command "Write-Host \"%~1\" -ForegroundColor Green" powershell -NoProfile -Command "Write-Host \"%~1\" -ForegroundColor Green"
exit /b exit /b