1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 12:30:58 -04:00

Add unfinished cron task

This commit is contained in:
AnxietyisReal 2023-01-09 05:43:24 +11:00
parent b45b8ee901
commit ad76dfa17e
2 changed files with 22 additions and 0 deletions

View File

@ -28,6 +28,7 @@
"discord.js": "14.7.1",
"moment": "2.29.4",
"ms": "2.1.3",
"node-cron": "3.0.2",
"sequelize": "6.28.0",
"sqlite3": "5.1.4",
"systeminformation": "5.16.9",
@ -36,6 +37,7 @@
},
"devDependencies": {
"@types/node": "18.11.18",
"@types/node-cron": "3.0.7",
"ts-node": "10.9.1"
}
}

View File

@ -4,6 +4,8 @@ const client = new TClient;
client.init();
import fs from 'node:fs';
import MPDB from './models/MPServer';
//import cron from 'node-cron';
//import {exec} from 'node:child_process';
import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interfaces';
client.on('ready', async()=>{
@ -29,6 +31,7 @@ client.on('ready', async()=>{
})
}, 500000);
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
//console.log('Total cron tasks: ' + cron.getTasks().size);
console.log(client.config.botSwitches);
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
@ -174,3 +177,20 @@ setInterval(async()=>{
client.guilds.cache.get(client.config.mainServer.id).commands.fetch().then((commands)=>(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send(`:pencil: Pushed \`[${formattedDate}, ${total}]\` to </rank leaderboard:${commands.find(x=>x.name == 'rank').id}>`))
}
}, 5000)
// Check Windows Updates at 6PM Sydney Time every Tuesday and Thursday
// 0 18 * * 2,4
/*
cron.schedule('* * * * *', async function(){
const x = await (client.channels.resolve(client.config.mainServer.channels.thismeanswar) as Discord.TextChannel).send('Checking Windows Updates...')
exec('D:/Bots-Housing/wu.ps1', {'shell':'powershell.exe'}, (err:Error, stdout)=>{
if (err){
x.edit('Powershell script caught an error, see console.');
console.log(err.stack)
} else if (stdout.includes('You\'re up to date')){
x.edit('The system is up to date.')
} else if (stdout.includes('Updates available')){
x.edit(`\`\`\`${stdout}\`\`\``)
}
});
})*/