Skip to content

Commit

Permalink
Fix initialization of toonsData array
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandward committed Mar 12, 2024
1 parent d9ccebe commit 1767725
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion commands/census/toons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand Down

0 comments on commit 1767725

Please sign in to comment.