mirror of
https://github.com/jcreek/MupBot.git
synced 2026-07-12 18:33:44 +00:00
feat(*): Add ability to run functions at 8am every day
This commit is contained in:
@@ -2,6 +2,8 @@ const { generateEmbedMessage, trim } = require('./helpers.js');
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
dailyTasks: function (client) {
|
||||||
|
},
|
||||||
matchCommand: function (Discord, config, logger, message, command, args) {
|
matchCommand: function (Discord, config, logger, message, command, args) {
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 'help':
|
case 'help':
|
||||||
|
|||||||
@@ -3,14 +3,22 @@ const winston = require('winston');
|
|||||||
const Elasticsearch = require('winston-elasticsearch');
|
const Elasticsearch = require('winston-elasticsearch');
|
||||||
const config = require('./config.json');
|
const config = require('./config.json');
|
||||||
const { initialiseLogger } = require('./logger.js');
|
const { initialiseLogger } = require('./logger.js');
|
||||||
const { matchCommand } = require('./commands.js');
|
const { matchCommand, dailyTasks } = require('./commands.js');
|
||||||
const client = new Discord.Client();
|
const client = new Discord.Client();
|
||||||
const logger = initialiseLogger(config, winston, Elasticsearch);
|
const logger = initialiseLogger(config, winston, Elasticsearch);
|
||||||
|
|
||||||
client.login(config.token);
|
client.login(config.token);
|
||||||
client.once('ready', () =>{
|
client.once('ready', () => {
|
||||||
logger.info('MupBot logged in successfully!');
|
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) {
|
client.on('message', function (message) {
|
||||||
// If someone tags the bot
|
// If someone tags the bot
|
||||||
|
|||||||
Reference in New Issue
Block a user