added silverbullets, added gettimeout command

This commit is contained in:
2025-07-06 22:05:53 +02:00
parent c6e5c76187
commit fe5c071900
4 changed files with 43 additions and 7 deletions

17
bot/lib/dateManager.ts Normal file
View File

@@ -0,0 +1,17 @@
export function buildTimeString(time1: number, time2: number) {
const diff = Math.abs(time1 - time2);
const timeobj = {
day: Math.floor(diff / (1000 * 60 * 60 * 24)),
hour: Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
minute: Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)),
second: Math.floor((diff % (1000 * 60)) / 1000)
};
const stringarray: string[] = [];
for (const [unit, value] of Object.entries(timeobj)) {
if (value === 0) continue;
if (unit === 'second' && timeobj.day > 0) continue;
stringarray.push(`${value} ${unit}${value === 1 ? '' : 's'}`);
};
const last = stringarray.pop();
return stringarray.length === 0 ? last : stringarray.join(', ') + " and " + last;
};