From 17677254429054b957e280ce64cf9602d33980a6 Mon Sep 17 00:00:00 2001 From: Ryan David Ward Date: Tue, 12 Mar 2024 16:44:15 -0500 Subject: [PATCH] Fix initialization of toonsData array --- commands/census/toons.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/commands/census/toons.ts b/commands/census/toons.ts index 869ff18..3d624a6 100644 --- a/commands/census/toons.ts +++ b/commands/census/toons.ts @@ -49,7 +49,7 @@ export async function execute(interaction: CommandInteraction) { const { options } = interaction; let discordId = interaction.user.id as string; - let toonsData: ActiveToons[]; + let toonsData: ActiveToons[] = []; if (!options.get('user') && !options.get('name')) { discordId = interaction.user.id as string; @@ -64,6 +64,12 @@ export async function execute(interaction: CommandInteraction) { discordId = toonsData[0].DiscordId; } + if (toonsData.length === 0) { + throw new Error( + ':x: No toons found. Make sure to use autocomplete to find the toon you are looking for.', + ); + } + const statusOrder = ['Main', 'Alt', 'Bot', 'Dropped']; const embed = new EmbedBuilder()