aboutsummaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 21:03:38 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 21:03:38 -0400
commit855aa36c46e250fd3063eb200d784903a8c388d3 (patch)
treefb883fcfc9addc0a5a23e200d04ae456dd29de1c /src/tasks
parenta2eee77d300723bc1e3e2d75cfda3c1d457b3b8c (diff)
downloadtanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.gz
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.tar.bz2
tanzanite-855aa36c46e250fd3063eb200d784903a8c388d3.zip
performance improvements & fixes
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/removeExpiredPunishements.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts
index d787063..69130ee 100644
--- a/src/tasks/removeExpiredPunishements.ts
+++ b/src/tasks/removeExpiredPunishements.ts
@@ -1,4 +1,4 @@
-import { BushGuild, BushTask } from '@lib';
+import { BushGuild, BushTask, BushUser } from '@lib';
import { Op } from 'sequelize';
import { ActivePunishment, ActivePunishmentType } from '../lib/models/ActivePunishment';
@@ -30,22 +30,21 @@ export default class RemoveExpiredPunishmentsTask extends BushTask {
for (const entry of expiredEntries) {
const guild = client.guilds.cache.get(entry.guild) as BushGuild;
const member = guild.members.cache.get(entry.user);
+ const user = (await util.resolveNonCachedUser(entry.user)) as BushUser;
- if (!guild) {
- await entry.destroy();
- continue;
- }
+ if (!guild) continue;
switch (entry.type) {
case ActivePunishmentType.BAN: {
- const result = await guild.unban({ user: entry.user, reason: 'Punishment expired.' });
+ if (!user) throw new Error(`user is undefined`);
+ const result = await guild.unban({ user: user, reason: 'Punishment expired.' });
if (['success', 'user not banned'].includes(result)) await entry.destroy();
else throw new Error(result);
void client.logger.verbose(`removeExpiredPunishments`, `Unbanned ${entry.user}.`);
break;
}
case ActivePunishmentType.BLOCK: {
- //todo
+ //todo once blocks are added
break;
}
case ActivePunishmentType.MUTE: {