refactor(arabot): insert awaits to schedule creators

This commit is contained in:
Anthony Berg 2024-01-06 02:30:05 +00:00
parent b6b50ea450
commit d90c985cec
2 changed files with 31 additions and 22 deletions

View File

@ -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,
);
}

View File

@ -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