feat(*): Add ability to run functions at 8am every day

This commit is contained in:
2021-01-29 19:35:19 +00:00
parent 6835154e9b
commit 51a8fc9697
2 changed files with 13 additions and 3 deletions
+2
View File
@@ -2,6 +2,8 @@ const { generateEmbedMessage, trim } = require('./helpers.js');
const axios = require('axios');
module.exports = {
dailyTasks: function (client) {
},
matchCommand: function (Discord, config, logger, message, command, args) {
switch(command) {
case 'help':
+11 -3
View File
@@ -3,14 +3,22 @@ const winston = require('winston');
const Elasticsearch = require('winston-elasticsearch');
const config = require('./config.json');
const { initialiseLogger } = require('./logger.js');
const { matchCommand } = require('./commands.js');
const { matchCommand, dailyTasks } = require('./commands.js');
const client = new Discord.Client();
const logger = initialiseLogger(config, winston, Elasticsearch);
client.login(config.token);
client.once('ready', () =>{
client.once('ready', () => {
logger.info('MupBot logged in successfully!');
})
setInterval(function () {
const hour = new Date().getHours();
if (hour == 8) {
// Run the daily tasks at 8am every day (server time)
dailyTasks(client);
}
}, 1000 * 60 * 60); // every hour
});
client.on('message', function (message) {
// If someone tags the bot