mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Add unfinished cron task
This commit is contained in:
parent
47a936837f
commit
68e35562f7
@ -28,6 +28,7 @@
|
|||||||
"discord.js": "14.7.1",
|
"discord.js": "14.7.1",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"ms": "2.1.3",
|
"ms": "2.1.3",
|
||||||
|
"node-cron": "3.0.2",
|
||||||
"sequelize": "6.28.0",
|
"sequelize": "6.28.0",
|
||||||
"sqlite3": "5.1.4",
|
"sqlite3": "5.1.4",
|
||||||
"systeminformation": "5.16.9",
|
"systeminformation": "5.16.9",
|
||||||
@ -36,6 +37,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "18.11.18",
|
"@types/node": "18.11.18",
|
||||||
|
"@types/node-cron": "3.0.7",
|
||||||
"ts-node": "10.9.1"
|
"ts-node": "10.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/index.ts
20
src/index.ts
@ -4,6 +4,8 @@ const client = new TClient;
|
|||||||
client.init();
|
client.init();
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import MPDB from './models/MPServer';
|
import MPDB from './models/MPServer';
|
||||||
|
//import cron from 'node-cron';
|
||||||
|
//import {exec} from 'node:child_process';
|
||||||
import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interfaces';
|
import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interfaces';
|
||||||
|
|
||||||
client.on('ready', async()=>{
|
client.on('ready', async()=>{
|
||||||
@ -29,6 +31,7 @@ client.on('ready', async()=>{
|
|||||||
})
|
})
|
||||||
}, 500000);
|
}, 500000);
|
||||||
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
|
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);
|
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')}\`\`\``);
|
(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}>`))
|
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)
|
}, 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}\`\`\``)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})*/
|
Loading…
Reference in New Issue
Block a user