mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Add cronjob task for previous commit.
This commit is contained in:
parent
888ab25280
commit
a68b3fc723
11
src/index.ts
11
src/index.ts
@ -2,12 +2,14 @@ import Discord from 'discord.js';
|
|||||||
import TClient from './client.js';
|
import TClient from './client.js';
|
||||||
const client = new TClient;
|
const client = new TClient;
|
||||||
client.init();
|
client.init();
|
||||||
|
import cron from 'node-cron';
|
||||||
import Logger from './helpers/Logger.js';
|
import Logger from './helpers/Logger.js';
|
||||||
import YTModule from './modules/YTModule.js';
|
import YTModule from './modules/YTModule.js';
|
||||||
import MPModule, {refreshTimerSecs} from './modules/MPModule.js';
|
import MPModule, {refreshTimerSecs} from './modules/MPModule.js';
|
||||||
import UsernameHelper from './helpers/UsernameHelper.js';
|
import UsernameHelper from './helpers/UsernameHelper.js';
|
||||||
import {Punishment} from 'src/interfaces';
|
import {Punishment} from 'src/interfaces';
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync} from 'node:fs';
|
||||||
|
import {exec} from 'node:child_process';
|
||||||
|
|
||||||
// Error handler
|
// Error handler
|
||||||
function _(error:Error, type:string) {
|
function _(error:Error, type:string) {
|
||||||
@ -69,3 +71,12 @@ if (client.config.botSwitches.dailyMsgsBackup) {
|
|||||||
client.userLevels.dataSweeper();
|
client.userLevels.dataSweeper();
|
||||||
}
|
}
|
||||||
// Cronjob tasks
|
// Cronjob tasks
|
||||||
|
|
||||||
|
// UFW reject cronjob - every minute through 30 to 50.
|
||||||
|
cron.schedule('30-50 * * * *', async()=>{
|
||||||
|
exec('sudo ./ufwReject.sh', {shell: 'bash'}, (error, stdout, stderr)=>{
|
||||||
|
if (error) return Logger.console('error', 'Cron:ufwReject', `Job ran into an error: ${error.message}`);
|
||||||
|
if (stderr) return Logger.console('error', 'Cron:ufwReject', `Process ran into an error: ${stderr}`);
|
||||||
|
else if (stdout.includes('Done populating UFW reject rule')) return Logger.console('log', 'Cron:ufwReject', 'Job completed');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user