From f74a0fd07e13e85df9aefafea17622ccbed5d3cf Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 8 Jul 2021 14:15:54 -0400 Subject: [PATCH] error fix --- src/intervals/autoRelease.ts | 104 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/intervals/autoRelease.ts b/src/intervals/autoRelease.ts index 21aa132..81a41c5 100644 --- a/src/intervals/autoRelease.ts +++ b/src/intervals/autoRelease.ts @@ -1,52 +1,52 @@ -import { TextChannel } from 'eris'; -import { Client, RichEmbed } from '../class'; - -let interval: NodeJS.Timeout; - -export default function checkLock(client: Client): NodeJS.Timeout { - interval = setInterval(async () => { - try { - const moderations = await client.db.Moderation.find(); - const judgements = await client.db.Judgement.find().lean().exec(); - judgements.forEach(async (judgement) => { - if (!judgement.expires) return; - if (new Date() > judgement.expires) { - await client.db.Judgement.deleteOne(({ _id: judgement._id })); - const log = client.guilds.get(this.client.config.guildID).channels.get('611584771356622849'); - const embed = new RichEmbed(); - embed.setTitle('Judgement - Rescind'); - embed.addField('Member', `<@${judgement.userID}>`, true); - embed.addField('Rescinded by', 'SYSTEM', true); - embed.setFooter(this.client.user.username, this.client.user.avatarURL); - embed.setTimestamp(); - log.createMessage({ embed }).catch(() => {}); - } - }); - moderations.forEach(async (moderation) => { - if (!moderation.expiration) return; - if (moderation.expiration.processed) return; - if (new Date() > moderation.expiration.date) { - await moderation.updateOne({ 'expiration.processed': true }); - - const system = client.guilds.get(client.config.guildID).members.get(client.user.id); - switch (moderation.type) { - case 5: - await client.util.moderation.unban(moderation.userID, system); - break; - case 2: - if (await client.db.local.muted.get(`muted-${moderation.userID}`) === true) { - await client.util.moderation.unmute(moderation.userID, system); - } - break; - default: - break; - } - client.util.signale.complete(`Released member ${moderation.userID} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`); - } - }); - } catch (error) { - await client.util.handleError(error); - } - }, 10000); - return interval; -} +import { TextChannel } from 'eris'; +import { Client, RichEmbed } from '../class'; + +let interval: NodeJS.Timeout; + +export default function checkLock(client: Client): NodeJS.Timeout { + interval = setInterval(async () => { + try { + const moderations = await client.db.Moderation.find(); + const judgements = await client.db.Judgement.find().lean().exec(); + judgements.forEach(async (judgement) => { + if (!judgement.expires) return; + if (new Date() > judgement.expires) { + await client.db.Judgement.deleteOne(({ _id: judgement._id })); + const log = client.guilds.get(client.config.guildID).channels.get('611584771356622849'); + const embed = new RichEmbed(); + embed.setTitle('Judgement - Rescind'); + embed.addField('Member', `<@${judgement.userID}>`, true); + embed.addField('Rescinded by', 'SYSTEM', true); + embed.setFooter(client.user.username, client.user.avatarURL); + embed.setTimestamp(); + log.createMessage({ embed }).catch(() => {}); + } + }); + moderations.forEach(async (moderation) => { + if (!moderation.expiration) return; + if (moderation.expiration.processed) return; + if (new Date() > moderation.expiration.date) { + await moderation.updateOne({ 'expiration.processed': true }); + + const system = client.guilds.get(client.config.guildID).members.get(client.user.id); + switch (moderation.type) { + case 5: + await client.util.moderation.unban(moderation.userID, system); + break; + case 2: + if (await client.db.local.muted.get(`muted-${moderation.userID}`) === true) { + await client.util.moderation.unmute(moderation.userID, system); + } + break; + default: + break; + } + client.util.signale.complete(`Released member ${moderation.userID} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`); + } + }); + } catch (error) { + await client.util.handleError(error); + } + }, 10000); + return interval; +}