From 1169e970a231213e15cad0e9d58c39c214312fb2 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Sat, 16 Dec 2023 01:03:31 +0530 Subject: [PATCH 1/3] fix/service binding changes --- wrangler.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrangler.toml b/wrangler.toml index 08217c1..e41e127 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -10,7 +10,7 @@ kv_namespaces = [ { binding = "CronJobsTimestamp", id = "6fbc191da931473393d5fbe612251d29" } ] services = [ - { binding = "DISCORD_BOT", service = "discord-slash-commands", environment = "staging" } + { binding = "DISCORD_BOT", service = "discord-slash-commands", environment = "production" } ] [env.production] From b5f9804df59a8beb2f655a673fe32c12ff17a091 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Sat, 16 Dec 2023 01:26:07 +0530 Subject: [PATCH 2/3] refactor: updates wrangler environment for service binding --- wrangler.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrangler.toml b/wrangler.toml index e41e127..2af8848 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -10,7 +10,7 @@ kv_namespaces = [ { binding = "CronJobsTimestamp", id = "6fbc191da931473393d5fbe612251d29" } ] services = [ - { binding = "DISCORD_BOT", service = "discord-slash-commands", environment = "production" } + { binding = "DISCORD_BOT", service = "discord-slash-commands" } ] [env.production] @@ -18,7 +18,7 @@ kv_namespaces = [ { binding = "CronJobsTimestamp", id = "3a10f726c95d4afea9dee5fd00f029b9" } ] services = [ - { binding = "DISCORD_BOT", service = "discord-slash-commands", environment = "production" } + { binding = "DISCORD_BOT", service = "discord-slash-commands" } ] [triggers] From a6580569198808c4e8db9119f184efccb91b92e4 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Sat, 16 Dec 2023 01:40:25 +0530 Subject: [PATCH 3/3] fix: removes 4hr cron --- src/worker.ts | 10 ++++------ wrangler.toml | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/worker.ts b/src/worker.ts index c1daf9a..ea872dd 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -1,18 +1,16 @@ -import { addMissedUpdatesRole, callDiscordNicknameBatchUpdate, ping } from './handlers/scheduledEventHandler'; +import { addMissedUpdatesRole, callDiscordNicknameBatchUpdate } from './handlers/scheduledEventHandler'; import { env } from './types/global.types'; -const EVERY_4_HOURS = '0 */4 * * *'; const EVERY_6_HOURS = '0 */6 * * *'; const EVERY_12_HOURS = '0 */12 * * *'; export default { + // eslint-disable-next-line no-unused-vars async scheduled(req: ScheduledController, env: env, ctx: ExecutionContext) { switch (req.cron) { - case EVERY_4_HOURS: - ctx.waitUntil(ping(env)); - break; - case EVERY_6_HOURS: + case EVERY_6_HOURS: { return await callDiscordNicknameBatchUpdate(env); + } case EVERY_12_HOURS: { return await addMissedUpdatesRole(env); } diff --git a/wrangler.toml b/wrangler.toml index 2af8848..da44cc5 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -22,7 +22,7 @@ services = [ ] [triggers] -crons = ["0 */4 * * *", "0 */6 * * *","0 */12 * * *" ] +crons = ["0 */6 * * *","0 */12 * * *" ] # # Durable Object binding - For more information: https://developers.cloudflare.com/workers/runtime-apis/durable-objects # [[durable_objects]]