feat: update environment variables and refactor timezone handling in index.js

This commit is contained in:
Fd
2026-02-20 16:32:27 +07:00
parent 811253dac1
commit 30d7d298df
2 changed files with 6 additions and 8 deletions
+3 -4
View File
@@ -1,8 +1,7 @@
TOKEN=your_discord_token_here TOKEN=your_discord_token_here
CHANNEL_ID=voice_channel_id_here CHANNEL_ID=voice_channel_id_here
MESSAGE_CRON="" TZ=Asia/Jakarta
MESSAGE="pong" CRON="0 3 * * *"
RAMADHAN_CRON=0 5 * * * START_DATE="2026-02-19T00:00:00.000Z"
START_DATE="2026-02-18"
SELF_DEAF=true SELF_DEAF=true
SELF_MUTE=true SELF_MUTE=true
+3 -4
View File
@@ -7,9 +7,8 @@ import generateMeme from "./meme.js";
const TOKEN = process.env.TOKEN; const TOKEN = process.env.TOKEN;
const channelId = process.env.CHANNEL_ID; 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 start = DateTime.fromISO(process.env.START_DATE, { zone: TIMEZONE });
const days = { const days = {
@@ -69,7 +68,7 @@ cron.schedule(process.env.CRON, async () => {
const now = DateTime.now().setZone(TIMEZONE); const now = DateTime.now().setZone(TIMEZONE);
const diff = Math.floor(now.startOf('day').diff(start.startOf('day'), 'days').days) + 1; 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)); 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({ channel.send({
files: [{ files: [{
attachment: image, attachment: image,
@@ -84,7 +83,7 @@ cron.schedule(process.env.CRON, async () => {
} }
}, { }, {
scheduled: true, scheduled: true,
timezone: "Asia/Jakarta", timezone: TIMEZONE,
}); });
client.login(TOKEN).then(() => { client.login(TOKEN).then(() => {