From c1a164823258241d4f41a26d5ba32115905803c4 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 21:41:39 -0500 Subject: [PATCH 01/18] Replace any with type variable JS-0323 --- commands/owner/csClassPoll.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index d3a0107..1105c4f 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -85,7 +85,7 @@ export default { } as ICommand; // Splits any size list into lists of at most `max_list_len` -function split_list(list: Array, max_list_len: number) { +function split_list(list: T[], max_list_len: number):T[][] { let class_chunks = []; for (let i = 0; i < list.length; i += max_list_len) { class_chunks.push(list.slice(i, i + max_list_len)); From ec80927dcd5388ce2999d41516cbb43228af6b79 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 21:51:12 -0500 Subject: [PATCH 02/18] Move non export functions to top JS-0357 --- commands/owner/csClassPoll.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index 1105c4f..b27ef54 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -9,6 +9,23 @@ import { ICommand } from "wokcommands"; import { classModel, IClass } from "../../models/classModel"; import { checkForRoles } from "../../rolesOps"; +// Splits any size list into lists of at most `max_list_len` +function split_list(list: T[], max_list_len: number):T[][] { + let class_chunks = []; + for (let i = 0; i < list.length; i += max_list_len) { + class_chunks.push(list.slice(i, i + max_list_len)); + } + return class_chunks; +} + +// consumes a Class and returns Message Selec tOption data +function create_option_from_class(_class: IClass): MessageSelectOptionData { + return { + label: _class.CODE, + value: _class.CODE, + description: _class.TITLE, + }; +} export default { name: "csClassPoll", category: "owner", @@ -83,21 +100,3 @@ export default { ); }, } as ICommand; - -// Splits any size list into lists of at most `max_list_len` -function split_list(list: T[], max_list_len: number):T[][] { - let class_chunks = []; - for (let i = 0; i < list.length; i += max_list_len) { - class_chunks.push(list.slice(i, i + max_list_len)); - } - return class_chunks; -} - -// consumes a Class and returns Message Selec tOption data -function create_option_from_class(_class: IClass): MessageSelectOptionData { - return { - label: _class.CODE, - value: _class.CODE, - description: _class.TITLE, - }; -} From 380d541951b6d76a25ced2a62c8f02e35f42e73d Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 21:52:21 -0500 Subject: [PATCH 03/18] Remove unused variables JS-0356 --- commands/user/uptime.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/commands/user/uptime.ts b/commands/user/uptime.ts index c2688cc..7aa8c5a 100644 --- a/commands/user/uptime.ts +++ b/commands/user/uptime.ts @@ -12,10 +12,6 @@ export default { requiredPermissions: ["SEND_MESSAGES"], callback: async ({ client, interaction }) => { - // Command information - const id = interaction.user.id; - const chan = interaction.channel as TextChannel; - // Computed values const time = client.uptime!; const days = Math.floor(time / 86400000); From fc980777c62f767c3890bc19e2af2b5e861ff177 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 21:54:15 -0500 Subject: [PATCH 04/18] add missing awaits JS-0336 --- commands/owner/csClassPoll.ts | 4 ++-- commands/owner/staffPoll.ts | 2 +- commands/owner/yearPoll.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index b27ef54..b971d3f 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -10,7 +10,7 @@ import { classModel, IClass } from "../../models/classModel"; import { checkForRoles } from "../../rolesOps"; // Splits any size list into lists of at most `max_list_len` -function split_list(list: T[], max_list_len: number):T[][] { +function split_list(list: T[], max_list_len: number): T[][] { let class_chunks = []; for (let i = 0; i < list.length; i += max_list_len) { class_chunks.push(list.slice(i, i + max_list_len)); @@ -37,7 +37,7 @@ export default { ownerOnly: true, callback: async ({ client, interaction: msgInt }) => { - if (!checkForRoles(msgInt.guild!)) { + if (!(await checkForRoles(msgInt.guild!))) { msgInt.reply( "Please run the `/ createRoles` command in this server to create the necessary roles for this poll!" ); diff --git a/commands/owner/staffPoll.ts b/commands/owner/staffPoll.ts index c35d75c..b0601bf 100644 --- a/commands/owner/staffPoll.ts +++ b/commands/owner/staffPoll.ts @@ -59,7 +59,7 @@ export default { ); // Send the embed and message component rows - if (!checkForRoles(msgInt.guild!)) { + if (!(await checkForRoles(msgInt.guild!))) { msgInt.reply( "Please run the `/createRoles` command in this server to create the necessary roles for this poll!" ); diff --git a/commands/owner/yearPoll.ts b/commands/owner/yearPoll.ts index 17f6e62..2e64eb3 100644 --- a/commands/owner/yearPoll.ts +++ b/commands/owner/yearPoll.ts @@ -67,7 +67,7 @@ export default { ); // Send the embed and message component rows - if (!checkForRoles(msgInt.guild!)) { + if (!(await checkForRoles(msgInt.guild!))) { msgInt.reply({ content: "Please run the /createRoles command in this server to create the necessary roles for this poll!", From f682488c2f194715eef4f69557fea3b13d485e63 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:04:39 -0500 Subject: [PATCH 05/18] resolve use of eval() like method JS-0330 --- commands/owner/csClassPoll.ts | 7 +++---- util.ts | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 util.ts diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index b971d3f..0538658 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -8,6 +8,7 @@ import chalk from "chalk"; import { ICommand } from "wokcommands"; import { classModel, IClass } from "../../models/classModel"; import { checkForRoles } from "../../rolesOps"; +import { sleep } from "../../util"; // Splits any size list into lists of at most `max_list_len` function split_list(list: T[], max_list_len: number): T[][] { @@ -82,10 +83,8 @@ export default { } else { msgInt.channel!.send({ components: row_chunks[index] }); } - // await on a new promise that resolves itself after a delay of 200 ms - await new Promise((resolve) => { - setTimeout(resolve, 200); - }); + + await sleep(200); } // Log the command usage diff --git a/util.ts b/util.ts new file mode 100644 index 0000000..ccf6b87 --- /dev/null +++ b/util.ts @@ -0,0 +1,4 @@ +export function sleep(ms: number) { + // Create new promise that resolves itself after a delay of + return new Promise((resolve: Function) => setTimeout(resolve, ms)); +} From 6784379d2dac376ee8a2e051df35bd8f5f4ad6fa Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:13:44 -0500 Subject: [PATCH 06/18] remove non-null assertion Swap to reply to not have to check for null --- commands/owner/csClassPoll.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index 0538658..588cb48 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -38,7 +38,11 @@ export default { ownerOnly: true, callback: async ({ client, interaction: msgInt }) => { - if (!(await checkForRoles(msgInt.guild!))) { + if (msgInt.guild === null) { + console.log(chalk.red("No guild")); + return; + } + if (!(await checkForRoles(msgInt.guild))) { msgInt.reply( "Please run the `/ createRoles` command in this server to create the necessary roles for this poll!" ); @@ -81,7 +85,7 @@ export default { msgInt.reply({ embeds: [infoEmbed], components: row_chunks[index] }); } else { - msgInt.channel!.send({ components: row_chunks[index] }); + msgInt.reply({ components: row_chunks[index] }); } await sleep(200); From c773ed526390e446005869b22e752161af68325e Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:13:53 -0500 Subject: [PATCH 07/18] remove non-null assertions --- commands/owner/staffPoll.ts | 6 +++++- commands/owner/yearPoll.ts | 6 +++++- commands/user/uptime.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/commands/owner/staffPoll.ts b/commands/owner/staffPoll.ts index b0601bf..8b6cc06 100644 --- a/commands/owner/staffPoll.ts +++ b/commands/owner/staffPoll.ts @@ -58,8 +58,12 @@ export default { ) ); + if (msgInt.guild === null) { + console.log(chalk.red("No guild")); + return; + } // Send the embed and message component rows - if (!(await checkForRoles(msgInt.guild!))) { + if (!(await checkForRoles(msgInt.guild))) { msgInt.reply( "Please run the `/createRoles` command in this server to create the necessary roles for this poll!" ); diff --git a/commands/owner/yearPoll.ts b/commands/owner/yearPoll.ts index 2e64eb3..01e74fd 100644 --- a/commands/owner/yearPoll.ts +++ b/commands/owner/yearPoll.ts @@ -66,8 +66,12 @@ export default { ) ); + if (msgInt.guild === null) { + console.log(chalk.red("No guild")); + return; + } // Send the embed and message component rows - if (!(await checkForRoles(msgInt.guild!))) { + if (!(await checkForRoles(msgInt.guild))) { msgInt.reply({ content: "Please run the /createRoles command in this server to create the necessary roles for this poll!", diff --git a/commands/user/uptime.ts b/commands/user/uptime.ts index 7aa8c5a..f03d769 100644 --- a/commands/user/uptime.ts +++ b/commands/user/uptime.ts @@ -13,7 +13,7 @@ export default { callback: async ({ client, interaction }) => { // Computed values - const time = client.uptime!; + const time = client.uptime !== null ? client.uptime : 0; const days = Math.floor(time / 86400000); const hours = Math.floor(time / 3600000) % 24; const minutes = Math.floor(time / 60000) % 60; From 84cac64b90793ba5a89ad87f7345882138950231 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:15:43 -0500 Subject: [PATCH 08/18] Use const declarations for variables that are never reassigned JS-0242 --- commands/owner/csClassPoll.ts | 4 ++-- rolesOps.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/owner/csClassPoll.ts b/commands/owner/csClassPoll.ts index 588cb48..37457e6 100644 --- a/commands/owner/csClassPoll.ts +++ b/commands/owner/csClassPoll.ts @@ -12,7 +12,7 @@ import { sleep } from "../../util"; // Splits any size list into lists of at most `max_list_len` function split_list(list: T[], max_list_len: number): T[][] { - let class_chunks = []; + const class_chunks: T[][] = []; for (let i = 0; i < list.length; i += max_list_len) { class_chunks.push(list.slice(i, i + max_list_len)); } @@ -52,7 +52,7 @@ export default { const classes = await classModel.find({}).sort({ CODE: 1 }); const class_chunks = split_list(classes, 25); - let rows: MessageActionRow[] = []; + const rows: MessageActionRow[] = []; for (let index = 0; index < class_chunks.length; index++) { const menu = new MessageSelectMenu(); menu.setCustomId(`csClassPoll+${index}`); diff --git a/rolesOps.ts b/rolesOps.ts index c890bc5..a950f81 100644 --- a/rolesOps.ts +++ b/rolesOps.ts @@ -119,7 +119,7 @@ export async function checkForRoles(guild: Guild): Promise { // Check if all roles exist in a guild // Return true if they do, false if they don't - let collection: boolean[] = []; + const collection: boolean[] = []; for (const group of await dbQuery()) { for (const element of group) { From 98f7f28e18808952c19167859f98bf29d7ca875b Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:26:26 -0500 Subject: [PATCH 09/18] not using await on async function JS-0116 --- commands/owner/yearPoll.ts | 4 ++-- commands/user/github.ts | 2 +- commands/user/help.ts | 2 +- commands/user/ping.ts | 2 +- commands/user/status.ts | 2 +- commands/user/uptime.ts | 2 +- commands/user/version.ts | 2 +- features/status-changer.ts | 2 +- features/statuspage.ts | 2 +- index.ts | 11 +++++++---- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/commands/owner/yearPoll.ts b/commands/owner/yearPoll.ts index 01e74fd..2042765 100644 --- a/commands/owner/yearPoll.ts +++ b/commands/owner/yearPoll.ts @@ -72,13 +72,13 @@ export default { } // Send the embed and message component rows if (!(await checkForRoles(msgInt.guild))) { - msgInt.reply({ + await msgInt.reply({ content: "Please run the /createRoles command in this server to create the necessary roles for this poll!", ephemeral: true, }); } else { - msgInt.reply({ embeds: [infoEmbed], components: [row] }); + await msgInt.reply({ embeds: [infoEmbed], components: [row] }); } // Log the command usage diff --git a/commands/user/github.ts b/commands/user/github.ts index 9ca20fe..f94f6d0 100644 --- a/commands/user/github.ts +++ b/commands/user/github.ts @@ -30,7 +30,7 @@ export default { .setDescription(description) .setFooter({ text: footer, iconURL: footerIcon }); - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/commands/user/help.ts b/commands/user/help.ts index 3c3030e..9bd3086 100644 --- a/commands/user/help.ts +++ b/commands/user/help.ts @@ -53,7 +53,7 @@ export default { .setDescription(description) .addFields(fields) .setFooter({ text: footer, iconURL: footerIcon }); - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/commands/user/ping.ts b/commands/user/ping.ts index 672d6b5..e9d5fec 100644 --- a/commands/user/ping.ts +++ b/commands/user/ping.ts @@ -26,7 +26,7 @@ export default { .setFooter({ text: footer, iconURL: footerIcon }); // Return the embed - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/commands/user/status.ts b/commands/user/status.ts index 22742c2..bd7a48d 100644 --- a/commands/user/status.ts +++ b/commands/user/status.ts @@ -30,7 +30,7 @@ export default { .setDescription(description) .setFooter({ text: footer, iconURL: footerIcon }); - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/commands/user/uptime.ts b/commands/user/uptime.ts index f03d769..b761a3a 100644 --- a/commands/user/uptime.ts +++ b/commands/user/uptime.ts @@ -34,7 +34,7 @@ export default { .setFooter({ text: footer, iconURL: footerIcon }); // Return the embed - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/commands/user/version.ts b/commands/user/version.ts index 5a5d42f..c039b87 100644 --- a/commands/user/version.ts +++ b/commands/user/version.ts @@ -26,7 +26,7 @@ export default { .setFooter({ text: footer, iconURL: footerIcon }); // Return the embed - interaction.reply({ embeds: [Embed] }); + await interaction.reply({ embeds: [Embed] }); // Log the command usage console.log( diff --git a/features/status-changer.ts b/features/status-changer.ts index c232230..0d46db6 100644 --- a/features/status-changer.ts +++ b/features/status-changer.ts @@ -1,6 +1,6 @@ import { Client } from "discord.js"; -export default async (client: Client) => { +export default (client: Client) => { const statusOptions = [ `/help | Ping: ${client.ws.ping}ms`, `V.${process.env.VERSION}`, diff --git a/features/statuspage.ts b/features/statuspage.ts index 2c09c0d..a555560 100644 --- a/features/statuspage.ts +++ b/features/statuspage.ts @@ -4,7 +4,7 @@ import { Client } from "discord.js"; export default (client: Client): void => { const updateStatus = async () => { // This function is called every 1 minutes and pings the network status page for uptime monitoring - axios.get( + await axios.get( `https://${process.env.UPTIME_KUMA_MONITOR_DOMAIN}/api/push/${process.env.UPTIME_KUMA_MONITOR_ID}?msg=OK&ping=${client.ws.ping}` ); setTimeout(updateStatus, 1000 * 60); diff --git a/index.ts b/index.ts index 3111af8..c85a073 100644 --- a/index.ts +++ b/index.ts @@ -24,7 +24,7 @@ const client = new DiscordJs.Client({ ], }); -client.on("ready", () => { +client.on("ready", async () => { if (client.user) { console.log(chalk.green(`Logged in as ${client.user.tag}!`)); console.log( @@ -32,9 +32,12 @@ client.on("ready", () => { ); // Check to make sure the roles exist in all servers console.log("Checking if all roles exist in servers."); - client.guilds.cache.forEach(async (guild) => { - checkForRoles(guild); - }); + + await Promise.all( + client.guilds.cache.map(async (guild) => { + await checkForRoles(guild); + }) + ); } const dbOptions = { From a434f192897af8b35baedb6f4e647b447a7980ce Mon Sep 17 00:00:00 2001 From: schiltz3 Date: Tue, 6 Sep 2022 03:29:02 +0000 Subject: [PATCH 10/18] Apply auto formatting changes --- util.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util.ts b/util.ts index ccf6b87..6f992af 100644 --- a/util.ts +++ b/util.ts @@ -1,4 +1,4 @@ -export function sleep(ms: number) { - // Create new promise that resolves itself after a delay of - return new Promise((resolve: Function) => setTimeout(resolve, ms)); -} +export function sleep(ms: number) { + // Create new promise that resolves itself after a delay of + return new Promise((resolve: Function) => setTimeout(resolve, ms)); +} From 3ebf80183c83b42eed6494775980e3423890a45b Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:30:08 -0500 Subject: [PATCH 11/18] remove unused variable JS-0356 --- commands/user/uptime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/user/uptime.ts b/commands/user/uptime.ts index b761a3a..17adffe 100644 --- a/commands/user/uptime.ts +++ b/commands/user/uptime.ts @@ -1,5 +1,5 @@ import chalk from "chalk"; -import { MessageEmbed, TextChannel } from "discord.js"; +import { MessageEmbed } from "discord.js"; import { ICommand } from "wokcommands"; export default { From 5bd4c69ebe6fad5dd491f753f6ed4eaa97f652ed Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:32:44 -0500 Subject: [PATCH 12/18] remove Function type --- util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.ts b/util.ts index 6f992af..7532b00 100644 --- a/util.ts +++ b/util.ts @@ -1,4 +1,4 @@ export function sleep(ms: number) { // Create new promise that resolves itself after a delay of - return new Promise((resolve: Function) => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); } From 79cf04aba4060d41c44c0e650ea69d0d182962f4 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:57:46 -0500 Subject: [PATCH 13/18] fix awaiting a non-promise --- index.ts | 2 +- rolesOps.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index c85a073..e0cf81b 100644 --- a/index.ts +++ b/index.ts @@ -35,7 +35,7 @@ client.on("ready", async () => { await Promise.all( client.guilds.cache.map(async (guild) => { - await checkForRoles(guild); + checkForRoles(guild); }) ); } diff --git a/rolesOps.ts b/rolesOps.ts index a950f81..bc54a4d 100644 --- a/rolesOps.ts +++ b/rolesOps.ts @@ -16,10 +16,11 @@ export async function checkIfCollectionsExist(model: Model) { } } async function dbQuery() { - const classes = await classModel.find({}); - const staff = await staffModel.find({}); - const years = await yearModel.find({}); - return [classes, staff, years]; + return await Promise.all([ + classModel.find({}), + staffModel.find({}), + yearModel.find({}), + ]); } export async function getUsersRoles(member: GuildMember): Promise { From 29b870111cc121f75dfe4f8fbccef82712a6d5d3 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 22:57:59 -0500 Subject: [PATCH 14/18] try callback for resolve --- util.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util.ts b/util.ts index 7532b00..e8606bc 100644 --- a/util.ts +++ b/util.ts @@ -1,4 +1,8 @@ export function sleep(ms: number) { // Create new promise that resolves itself after a delay of - return new Promise((resolve) => setTimeout(resolve, ms)); + return new Promise((resolve) => + setTimeout(function () { + resolve; + }, ms) + ); } From 5dfbeb5ba91d6985dc6c4e83c0641279c79983f5 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 23:00:04 -0500 Subject: [PATCH 15/18] return promise for all --- index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index e0cf81b..73d2091 100644 --- a/index.ts +++ b/index.ts @@ -34,8 +34,8 @@ client.on("ready", async () => { console.log("Checking if all roles exist in servers."); await Promise.all( - client.guilds.cache.map(async (guild) => { - checkForRoles(guild); + client.guilds.cache.map((guild) => { + return checkForRoles(guild); }) ); } From 1918b801ef5cd3e243c0471208f3fdb9a858786f Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 23:09:42 -0500 Subject: [PATCH 16/18] don't return in map --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 73d2091..ee5ec5e 100644 --- a/index.ts +++ b/index.ts @@ -35,7 +35,7 @@ client.on("ready", async () => { await Promise.all( client.guilds.cache.map((guild) => { - return checkForRoles(guild); + checkForRoles(guild); }) ); } From a5a6a983a0f415eba186aea5e49db996027af6c9 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 23:23:13 -0500 Subject: [PATCH 17/18] rewrite wait to specify resolve type --- index.ts | 1 + util.ts | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index ee5ec5e..49f69fa 100644 --- a/index.ts +++ b/index.ts @@ -10,6 +10,7 @@ import { checkForRoles, checkIfCollectionsExist } from "./rolesOps"; import { classModel } from "./models/classModel"; import { staffModel } from "./models/staffModel"; import { yearModel } from "./models/yearModel"; +import { sleep } from "./util"; // import all environment variables from .env file dotenv.config(); diff --git a/util.ts b/util.ts index e8606bc..6d492e6 100644 --- a/util.ts +++ b/util.ts @@ -1,8 +1,6 @@ export function sleep(ms: number) { // Create new promise that resolves itself after a delay of - return new Promise((resolve) => - setTimeout(function () { - resolve; - }, ms) + return new Promise((resolve: (args: void) => void) => + setTimeout(resolve, ms) ); } From 70cae6ab3ff66762cd60f0761db2d41c1295d553 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Mon, 5 Sep 2022 23:24:35 -0500 Subject: [PATCH 18/18] remove unused import --- index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/index.ts b/index.ts index 49f69fa..ee5ec5e 100644 --- a/index.ts +++ b/index.ts @@ -10,7 +10,6 @@ import { checkForRoles, checkIfCollectionsExist } from "./rolesOps"; import { classModel } from "./models/classModel"; import { staffModel } from "./models/staffModel"; import { yearModel } from "./models/yearModel"; -import { sleep } from "./util"; // import all environment variables from .env file dotenv.config();