From 72843bfeb145974b3063d09263e727f411cfe394 Mon Sep 17 00:00:00 2001 From: SKINMAKER Date: Fri, 7 Apr 2023 22:34:39 +0900 Subject: [PATCH] fix: webhook failed since not working as intended (#550) * fix: webhook failed since not working as intended * fix: match to milliseconds --- utils/Webhook.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/Webhook.ts b/utils/Webhook.ts index d0ddbf3..9932488 100644 --- a/utils/Webhook.ts +++ b/utils/Webhook.ts @@ -134,17 +134,17 @@ export const sendWebhook = async (target: Bot | Server, payload: WebhookPayload) } } - if(Date.now() - webhook.failedSince > 1000 * 60 * 60 * 24) { + if(!webhook.failedSince) { + await update.webhook(id, isBot ? 'bots' : 'servers', { + failedSince: Math.floor(Date.now() / 1000) + }) + } else if(Date.now() - webhook.failedSince * 1000 > 1000 * 60 * 60 * 24) { await update.webhook(id, isBot ? 'bots' : 'servers', { status: WebhookStatus.Disabled, failedSince: null, secret: null }) sendFailedMessage(target) - } else if(!webhook.failedSince) { - await update.webhook(id, isBot ? 'bots' : 'servers', { - failedSince: Date.now() - }) } return false }