aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/removePunishmentRole.ts
diff options
context:
space:
mode:
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}.`);
- }
- }
-}