From 30d7d298dfb50024044d27a5934731ee31221fb5 Mon Sep 17 00:00:00 2001 From: fdvkey Date: Fri, 20 Feb 2026 16:32:27 +0700 Subject: [PATCH] feat: update environment variables and refactor timezone handling in index.js --- .env.example | 7 +++---- index.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 96ca46f..8f7eb14 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,7 @@ TOKEN=your_discord_token_here CHANNEL_ID=voice_channel_id_here -MESSAGE_CRON="" -MESSAGE="pong" -RAMADHAN_CRON=0 5 * * * -START_DATE="2026-02-18" +TZ=Asia/Jakarta +CRON="0 3 * * *" +START_DATE="2026-02-19T00:00:00.000Z" SELF_DEAF=true SELF_MUTE=true \ No newline at end of file diff --git a/index.js b/index.js index 74a346f..7d2ba86 100644 --- a/index.js +++ b/index.js @@ -7,9 +7,8 @@ import generateMeme from "./meme.js"; const TOKEN = process.env.TOKEN; const channelId = process.env.CHANNEL_ID; -const TIMEZONE = "Asia/Jakarta"; +const TIMEZONE = process.env.TZ || "Asia/Jakarta"; -// Ramadan 2026 start date - parsed with consistent timezone const start = DateTime.fromISO(process.env.START_DATE, { zone: TIMEZONE }); const days = { @@ -69,7 +68,7 @@ cron.schedule(process.env.CRON, async () => { const now = DateTime.now().setZone(TIMEZONE); const diff = Math.floor(now.startOf('day').diff(start.startOf('day'), 'days').days) + 1; const image = await generateMeme("./assets/images/mr_crab.jpg", "SEMANGAT PUASA HARI " + (days[diff]?.toUpperCase() || "KE-" + diff), "YAA.... HARI " + (days[diff]?.toUpperCase() || "KE-" + diff)); - client.channels.fetch(process.env.CHANNEL_ID).then(channel => { + client.channels.fetch(channelId).then(channel => { channel.send({ files: [{ attachment: image, @@ -84,7 +83,7 @@ cron.schedule(process.env.CRON, async () => { } }, { scheduled: true, - timezone: "Asia/Jakarta", + timezone: TIMEZONE, }); client.login(TOKEN).then(() => {