merge dev to main #169

Merged
Anri merged 6 commits from dev into main 2024-09-17 22:57:55 +02:00
Showing only changes of commit 5816864066 - Show all commits

View file

@ -202,8 +202,19 @@ export const setTimeoutReminder = (
option: OptionReminder,
timeout: number,
) => {
return Number(
setTimeout(() => {
const setChunkedTimeout = (remainingTime: number) => {
// Maximum for setTimeout is Int32
if (remainingTime > 2147483647) {
// Schedule a 24-hour delay (24 * 60 * 60 * 1000), then check again
const dayChunk = 86400000;
return setTimeout(() => {
setChunkedTimeout(remainingTime - dayChunk);
}, dayChunk);
}
// Final timeout when remaining time is within limit
return setTimeout(() => {
deleteReminder(client, String(info.createdAt), info.userId).then((val) => {
if (val != true) {
throw val;
@ -211,8 +222,11 @@ export const setTimeoutReminder = (
sendReminder(client, info, option);
});
}, timeout * 1000),
);
}, remainingTime);
};
// Convert to milliseconds
return Number(setChunkedTimeout(timeout * 1000));
};
/**