error fix
parent
833066e2fc
commit
f74a0fd07e
|
@ -1,52 +1,52 @@
|
||||||
import { TextChannel } from 'eris';
|
import { TextChannel } from 'eris';
|
||||||
import { Client, RichEmbed } from '../class';
|
import { Client, RichEmbed } from '../class';
|
||||||
|
|
||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
|
|
||||||
export default function checkLock(client: Client): NodeJS.Timeout {
|
export default function checkLock(client: Client): NodeJS.Timeout {
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
const moderations = await client.db.Moderation.find();
|
const moderations = await client.db.Moderation.find();
|
||||||
const judgements = await client.db.Judgement.find().lean().exec();
|
const judgements = await client.db.Judgement.find().lean().exec();
|
||||||
judgements.forEach(async (judgement) => {
|
judgements.forEach(async (judgement) => {
|
||||||
if (!judgement.expires) return;
|
if (!judgement.expires) return;
|
||||||
if (new Date() > judgement.expires) {
|
if (new Date() > judgement.expires) {
|
||||||
await client.db.Judgement.deleteOne(({ _id: judgement._id }));
|
await client.db.Judgement.deleteOne(({ _id: judgement._id }));
|
||||||
const log = <TextChannel> client.guilds.get(this.client.config.guildID).channels.get('611584771356622849');
|
const log = <TextChannel> client.guilds.get(client.config.guildID).channels.get('611584771356622849');
|
||||||
const embed = new RichEmbed();
|
const embed = new RichEmbed();
|
||||||
embed.setTitle('Judgement - Rescind');
|
embed.setTitle('Judgement - Rescind');
|
||||||
embed.addField('Member', `<@${judgement.userID}>`, true);
|
embed.addField('Member', `<@${judgement.userID}>`, true);
|
||||||
embed.addField('Rescinded by', 'SYSTEM', true);
|
embed.addField('Rescinded by', 'SYSTEM', true);
|
||||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
embed.setFooter(client.user.username, client.user.avatarURL);
|
||||||
embed.setTimestamp();
|
embed.setTimestamp();
|
||||||
log.createMessage({ embed }).catch(() => {});
|
log.createMessage({ embed }).catch(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
moderations.forEach(async (moderation) => {
|
moderations.forEach(async (moderation) => {
|
||||||
if (!moderation.expiration) return;
|
if (!moderation.expiration) return;
|
||||||
if (moderation.expiration.processed) return;
|
if (moderation.expiration.processed) return;
|
||||||
if (new Date() > moderation.expiration.date) {
|
if (new Date() > moderation.expiration.date) {
|
||||||
await moderation.updateOne({ 'expiration.processed': true });
|
await moderation.updateOne({ 'expiration.processed': true });
|
||||||
|
|
||||||
const system = client.guilds.get(client.config.guildID).members.get(client.user.id);
|
const system = client.guilds.get(client.config.guildID).members.get(client.user.id);
|
||||||
switch (moderation.type) {
|
switch (moderation.type) {
|
||||||
case 5:
|
case 5:
|
||||||
await client.util.moderation.unban(moderation.userID, system);
|
await client.util.moderation.unban(moderation.userID, system);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (await client.db.local.muted.get<boolean>(`muted-${moderation.userID}`) === true) {
|
if (await client.db.local.muted.get<boolean>(`muted-${moderation.userID}`) === true) {
|
||||||
await client.util.moderation.unmute(moderation.userID, system);
|
await client.util.moderation.unmute(moderation.userID, system);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
client.util.signale.complete(`Released member ${moderation.userID} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`);
|
client.util.signale.complete(`Released member ${moderation.userID} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await client.util.handleError(error);
|
await client.util.handleError(error);
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue