move lookup to a sub command and add mem usage to the bot stats command
Some checks failed
Deploy to Dokku / docker (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
Lee
2024-07-07 01:34:27 +01:00
parent 843bb34fb4
commit 217b284f14
5 changed files with 54 additions and 10 deletions

View File

@ -37,4 +37,18 @@ public class StringUtils {
}
return inputString;
}
/**
* Formats bytes into a human-readable format
*
* @param bytes the bytes
* @return the formatted bytes
*/
public static String formatBytes(long bytes) {
int unit = 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
char pre = "KMGTPE".charAt(exp-1);
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
}