2022-08-30 14:26:56 +05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
2022-07-26 17:20:10 +05:00
|
|
|
module.exports.init = async function (client) {
|
|
|
|
setInterval(async () => {
|
2022-08-26 00:21:26 +05:00
|
|
|
const timestamp = Date.now() + (30 * 24 * 60 * 60 * 1000); // 1 month
|
2022-07-26 17:20:10 +05:00
|
|
|
const members = client.membersData.find({ transactions: { $gt: [] } });
|
2022-07-02 01:17:00 +05:00
|
|
|
|
2022-07-26 17:20:10 +05:00
|
|
|
for (const member of members) {
|
|
|
|
const transactions = member.transactions;
|
|
|
|
for await (const transaction of transactions) {
|
|
|
|
if (transaction.date < timestamp) {
|
|
|
|
const index = transactions.indexOf(transaction);
|
|
|
|
transactions.splice(index, 1);
|
|
|
|
await member.save();
|
2022-07-02 01:17:00 +05:00
|
|
|
}
|
|
|
|
}
|
2022-07-26 17:20:10 +05:00
|
|
|
}
|
2022-08-26 00:21:26 +05:00
|
|
|
}, (7 * 24 * 60 * 60 * 1000)); // every 7 days
|
2022-08-30 14:26:56 +05:00
|
|
|
|
|
|
|
/*
|
|
|
|
setInterval(async () => {
|
|
|
|
client.usersData.find({}, function (err, res) {
|
|
|
|
for (const user of res) {
|
|
|
|
client.users.fetch(user.id).then(u => {
|
|
|
|
if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) {
|
2022-10-03 20:21:42 +05:00
|
|
|
client.databaseCache.users.delete(u.id);
|
|
|
|
client.usersData.deleteOne({ id: u.id });
|
|
|
|
client.logger.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`);
|
2022-08-30 14:26:56 +05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, (7 * 24 * 60 * 60 * 1000)); // every 7 days
|
|
|
|
*/
|
2022-07-02 01:17:00 +05:00
|
|
|
};
|