Unfinished, do not pull.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const cron = require('node-cron');
|
||||
const client = require('..');
|
||||
const ModerationAction = require('../database/models/ModerationAction');
|
||||
const ModerationUtils = require('../database/models/ModerationUtils');
|
||||
|
||||
cron.schedule('* * * * * *', async () => {
|
||||
|
||||
const guilds = await ModerationAction.find({});
|
||||
|
||||
for (const guild of guilds) {
|
||||
const warns = await ModerationUtils.find({ guildId: guild.guildId });
|
||||
|
||||
//check if user is in the guild
|
||||
const guild = client.guilds.cache.get(guild.guildId);
|
||||
if (!guild) return;
|
||||
|
||||
for (const warn of warns) {
|
||||
const member = guild.members.cache.get(warn.userId);
|
||||
if (!member) return;
|
||||
|
||||
switch (warn.warns) {
|
||||
case guild.firstThreshold:
|
||||
member.send(guild.firstAction);
|
||||
break;
|
||||
case guild.secondThreshold:
|
||||
member.send(guild.secondAction);
|
||||
break;
|
||||
case guild.thirdThreshold:
|
||||
member.send(guild.thirdAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user