Skip to content

Commit

Permalink
Add conditional cron job listening based on environment
Browse files Browse the repository at this point in the history
  • Loading branch information
chimpdev committed Mar 24, 2024
1 parent 5fc05f3 commit 18b0848
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ client.create().start(process.env.DISCORD_CLIENT_TOKEN, {
checkVoteReminderMetadatas: true,
listenEvents: true
},
listenCrons: process.env.NODE_ENV === 'production',
registerCommands: false,
unregisterCommands: false,
});
Expand Down
10 changes: 6 additions & 4 deletions server/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ module.exports = class Client {
if (options.startup.updateClientActivity) this.updateClientActivity();
if (options.startup.checkVoteReminderMetadatas) this.checkVoteReminderMetadatas();

new CronJob('0 * * * *', this.checkVoiceActivity, null, true, 'Europe/Istanbul');
new CronJob('59 23 28-31 * *', this.saveMonthlyVotes, null, true, 'Europe/Istanbul');
new CronJob('0 0 * * *', this.updateClientActivity, null, true, 'Europe/Istanbul');
new CronJob('0 0 * * *', this.checkVoteReminderMetadatas, null, true, 'Europe/Istanbul');
if (options.listenCrons) {
new CronJob('0 * * * *', this.checkVoiceActivity, null, true, 'Europe/Istanbul');
new CronJob('59 23 28-31 * *', this.saveMonthlyVotes, null, true, 'Europe/Istanbul');
new CronJob('0 0 * * *', this.updateClientActivity, null, true, 'Europe/Istanbul');
new CronJob('0 0 * * *', this.checkVoteReminderMetadatas, null, true, 'Europe/Istanbul');
}
});
}

Expand Down
1 change: 1 addition & 0 deletions server/startup/registerCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ client.create().start(process.env.DISCORD_CLIENT_TOKEN, {
checkVoteReminderMetadatas: false,
listenEvents: false
},
listenCrons: false,
registerCommands: true,
unregisterCommands: false
});
1 change: 1 addition & 0 deletions server/startup/unregisterCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ client.create().start(process.env.DISCORD_CLIENT_TOKEN, {
checkVoteReminderMetadatas: false,
listenEvents: false
},
listenCrons: false,
registerCommands: false,
unregisterCommands: true
});

0 comments on commit 18b0848

Please sign in to comment.