From 9c3817d40ab56bd8973b2abc515cc64ce5605d43 Mon Sep 17 00:00:00 2001 From: 0x0Bug <98243573+0x0bug@users.noreply.github.com> Date: Wed, 22 Jul 2026 07:09:56 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA=D1=83=20=D0=BA?= =?UTF-8?q?=D1=8D=D1=88=D0=B0=20Discord=20PTB=20=D0=B2=20service.bat=20(#1?= =?UTF-8?q?5962)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service.bat | 71 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/service.bat b/service.bat index a9c807b..3aa1fb8 100644 --- a/service.bat +++ b/service.bat @@ -678,37 +678,22 @@ if !found_any_conflict!==1 ( :: Discord cache clearing 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!"=="y" set "CHOICE=Y" if /i "!CHOICE!"=="Y" ( - tasklist /FI "IMAGENAME eq Discord.exe" | findstr /I "Discord.exe" > nul - if !errorlevel!==0 ( - echo Discord is running, closing... - taskkill /IM Discord.exe /F > nul - if !errorlevel! == 0 ( - call :PrintGreen "Discord was successfully closed" - ) else ( - call :PrintRed "Unable to close Discord" - ) + set "discordFound=0" + if exist "%APPDATA%\discord\" ( + set "discordFound=1" + call :clear_discord_cache "Discord.exe" "Discord" "%APPDATA%\discord" ) - - set "discordCacheDir=%appdata%\discord" - - 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 exist "%APPDATA%\discordptb\" ( + set "discordFound=1" + call :clear_discord_cache "DiscordPTB.exe" "Discord PTB" "%APPDATA%\discordptb" ) + if !discordFound! equ 0 call :PrintRed "Discord and Discord PTB were not found" + set "discordFound=" ) echo: @@ -1133,6 +1118,42 @@ exit /b :: 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 powershell -NoProfile -Command "Write-Host \"%~1\" -ForegroundColor Green" exit /b