mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-29 00:24:58 +05:00
19 lines
602 B
JavaScript
19 lines
602 B
JavaScript
|
module.exports = {
|
||
|
async init(client) {
|
||
|
setInterval(async () => {
|
||
|
const timestamp = Date.now() + 30 * 24 * 60 * 60 * 1000; // day hour min sec msec / 1 month
|
||
|
const members = client.membersData.find({ transactions: { $gt: [] } });
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}, 24 * 60 * 60 * 1000); // every 24 hours
|
||
|
},
|
||
|
};
|