From d90c985ceca3aab310ccef67d1d0b60ee95c7a58 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Sat, 6 Jan 2024 02:30:05 +0000 Subject: [PATCH] refactor(arabot): insert awaits to schedule creators --- src/listeners/verification/joinVC.ts | 33 +++++++++++++++------------ src/listeners/verification/leaveVC.ts | 20 +++++++++------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/listeners/verification/joinVC.ts b/src/listeners/verification/joinVC.ts index 8c3a620..57089ef 100644 --- a/src/listeners/verification/joinVC.ts +++ b/src/listeners/verification/joinVC.ts @@ -56,7 +56,10 @@ import { rolesToString } from '#utils/formatter'; import IDs from '#utils/ids'; export class VerificationJoinVCListener extends Listener { - public constructor(context: Listener.LoaderContext, options: Listener.Options) { + public constructor( + context: Listener.LoaderContext, + options: Listener.Options, + ) { super(context, { ...options, event: 'voiceStateUpdate', @@ -151,14 +154,15 @@ export class VerificationJoinVCListener extends Listener { ]); // Start 15-minute timer if verifier does not join - this.container.tasks.create({ - name: 'verifyTimeout', - payload: { - channelId: channel.id, - userId: member.id, + await this.container.tasks.create( + { + name: 'verifyTimeout', + payload: { + channelId: channel.id, + userId: member.id, + }, }, - }, - 900_000 // 15 minutes + 900_000, // 15 minutes ); } @@ -507,13 +511,14 @@ export class VerificationJoinVCListener extends Listener { await giveVerificationRoles(user, info.roles); // Add timeout if they do not have activist role if (!info.roles.activist) { - this.container.tasks.create({ - name: 'verifyUnblock', - payload: { - userId: user.id, - guildId: guild.id, + await this.container.tasks.create( + { + name: 'verifyUnblock', + payload: { + userId: user.id, + guildId: guild.id, + }, }, - }, info.roles.vegan || info.roles.convinced ? 604800000 : 1814400000, ); } diff --git a/src/listeners/verification/leaveVC.ts b/src/listeners/verification/leaveVC.ts index 0537b32..e1d4084 100644 --- a/src/listeners/verification/leaveVC.ts +++ b/src/listeners/verification/leaveVC.ts @@ -37,7 +37,10 @@ import { fibonacci } from '#utils/maths'; import IDs from '#utils/ids'; export class VerificationLeaveVCListener extends Listener { - public constructor(context: Listener.LoaderContext, options: Listener.Options) { + public constructor( + context: Listener.LoaderContext, + options: Listener.Options, + ) { super(context, { ...options, event: 'voiceStateUpdate', @@ -103,14 +106,15 @@ export class VerificationLeaveVCListener extends Listener { // Creates the length of the time for the ban const banLength = fibonacci(incompleteCount) * 3600_000; - this.container.tasks.create({ - name: 'verifyUnblock', - payload: { - userId: user.id, - guildId: guild.id, + await this.container.tasks.create( + { + name: 'verifyUnblock', + payload: { + userId: user.id, + guildId: guild.id, + }, }, - }, - banLength, + banLength, ); await user.user