aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/removePunishmentRole.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-23 22:02:44 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-23 22:02:44 -0400
commitb015bec7f66526ec5e959ae99865845f4db4b181 (patch)
tree67538c9549b7e0f7cd6a97e9c82db8d8462a19c7 /src/tasks/removePunishmentRole.ts
parent5c242f597595b8db71875d92c0afe0a5947442a6 (diff)
downloadtanzanite-b015bec7f66526ec5e959ae99865845f4db4b181.tar.gz
tanzanite-b015bec7f66526ec5e959ae99865845f4db4b181.tar.bz2
tanzanite-b015bec7f66526ec5e959ae99865845f4db4b181.zip
feat: some shit
- fix breaking changes - refactored active punishments into one table - made listeners args have stricter types
Diffstat (limited to 'src/tasks/removePunishmentRole.ts')
-rw-r--r--src/tasks/removePunishmentRole.ts37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/tasks/removePunishmentRole.ts b/src/tasks/removePunishmentRole.ts
deleted file mode 100644
index 9830338..0000000
--- a/src/tasks/removePunishmentRole.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { BushGuildMember, BushTask } from '@lib';
-
-export default class RemovePunishmentRole extends BushTask {
- public constructor() {
- super('removePunishmentRole', {
- delay: 30_000, // 1/2 min
- runOnStart: true
- });
- }
- async exec(): Promise<void> {
- const expiredEntries = await this.client.util.findExpiredEntries('role');
- this.client.logger.verbose(
- `RemovePunishmentRoleTask`,
- `Queried punishment roles, found <<${expiredEntries.length}>> expired punishment roles.`
- );
-
- for (const entry of expiredEntries) {
- const guild = this.client.guilds.cache.get(entry.guild);
- const role = guild?.roles?.cache?.get(entry.role);
- if (!guild || !role) {
- await entry.destroy();
- continue;
- }
-
- const member = guild.members.cache.get(entry.user) as BushGuildMember;
- const result = await member.removeRole({
- reason: 'Punishment expired.',
- role: role,
- addToModlog: true
- });
- if (['success', 'failed to dm'].includes(result)) await entry.destroy();
- else throw result;
-
- this.client.logger.verbose(`RemovePunishmentRoleTask`, `Removed a punishment role from ${entry.user}.`);
- }
- }
-}