aboutsummaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-29 22:14:04 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-29 22:14:04 -0500
commitf0a9f894575871d498447c5de2b5f0f826b117b7 (patch)
treee3dc03b24ef7197699bc74ad47ebcbdc9cb19c1b /src/tasks
parent1182f63498c856111762e2766d6cdddf063f2a97 (diff)
downloadtanzanite-f0a9f894575871d498447c5de2b5f0f826b117b7.tar.gz
tanzanite-f0a9f894575871d498447c5de2b5f0f826b117b7.tar.bz2
tanzanite-f0a9f894575871d498447c5de2b5f0f826b117b7.zip
events
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/removeExpiredPunishements.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts
index 2b89f3d..3c18ebc 100644
--- a/src/tasks/removeExpiredPunishements.ts
+++ b/src/tasks/removeExpiredPunishements.ts
@@ -1,4 +1,5 @@
import { ActivePunishment, ActivePunishmentType, BushTask, type BushGuild, type BushUser } from '#lib';
+import assert from 'assert';
const { Op } = (await import('sequelize')).default;
export default class RemoveExpiredPunishmentsTask extends BushTask {
@@ -32,7 +33,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask {
switch (entry.type) {
case ActivePunishmentType.BAN: {
- if (!user) throw new Error(`user is undefined`);
+ assert(user);
const result = await guild.bushUnban({ user: user, reason: 'Punishment expired.' });
if (['success', 'user not banned'].includes(result)) await entry.destroy();
else throw new Error(result);
@@ -40,7 +41,14 @@ export default class RemoveExpiredPunishmentsTask extends BushTask {
break;
}
case ActivePunishmentType.BLOCK: {
- //todo once blocks are added
+ if (!member) {
+ await entry.destroy(); // channel overrides are removed when the member leaves the guild
+ continue;
+ }
+ const result = await member.unblock({ reason: 'Punishment expired.', channel: entry.extraInfo });
+ if (['success', 'user not blocked'].includes(result)) await entry.destroy();
+ else throw new Error(result);
+ void client.logger.verbose(`removeExpiredPunishments`, `Unblocked ${entry.user}.`);
break;
}
case ActivePunishmentType.MUTE: {