@echo off REM Set the path to the log file set LOG_FILE=./speedtest.csv REM Set your Discord webhook URL set WEBHOOK_URL=DISCORD_WEBHOOK_URL REM Set WAN Number set WAN=NUMBER REM Run the speedtest and parse the output for /f "tokens=6,7,8 delims=," %%A in ('speedtest-cli --csv') do ( set PING=%%A set DOWNLOAD=%%B set UPLOAD=%%C ) REM Check if the output is empty or contains errors if "%PING%"=="" ( echo Speedtest failed: Empty output exit /b 1 ) if "%PING%"=="ERROR" ( echo Speedtest failed: Error occurred exit /b 1 ) REM Check if the required fields are missing or invalid if "%PING%"=="" ( echo Missing or invalid speedtest fields: PING=%PING%, DOWNLOAD=%DOWNLOAD%, UPLOAD=%UPLOAD% exit /b 1 ) REM Convert the download and upload speeds to Mbps set /a DOWNLOAD_Mbps=DOWNLOAD / (1024*1024) set /a UPLOAD_Mbps=UPLOAD / (1024*1024) REM Append the result to the log file echo %date:~0,10% %time:~0,8%,%PING%,%DOWNLOAD_Mbps% Mbps,%UPLOAD_Mbps% Mbps >> "%LOG_FILE%" REM Prepare the payload for the Discord webhook set PAYLOAD={"content": "Speedtest Result:\nPing: %PING%\nDownload: %DOWNLOAD_Mbps% Mbps\nUpload: %UPLOAD_Mbps% Mbps"} REM Send the payload to the Discord webhook - If you don't want this, comment out this command curl -H "Content-Type: application/json" -X POST --data "{\"content\": null, \"embeds\": [{\"title\": \"Speedtest Result - WAN %WAN%\", \"description\": \"Time: %date:~0,10% %time:~0,8%\nPing: %PING% ms\nDownload: %DOWNLOAD_Mbps% mbps\nUpload: %UPLOAD_Mbps% mbps\", \"color\": 5814783}], \"attachments\": []}" %WEBHOOK_URL%