From 16bd70c9275865ce303e43ca4a4a31d55bcff13a Mon Sep 17 00:00:00 2001 From: BenW Date: Sat, 20 Jan 2024 12:06:10 +0000 Subject: [PATCH] fix: vatsim events max fields (#4) --- .github/CHANGELOG.md | 1 + src/commands/utils/vatsim/functions/vatsimEvents.ts | 2 +- src/events/contextInteractionHandler.ts | 10 +++++++++- src/events/slashCommandHandler.ts | 10 +++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 23459775..b4be78b8 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -2,5 +2,6 @@ Update _ January 2024 +- fix: vatsim events max fields (20/01/2024) - fix: user and mod log exclude id's (18/01/2024) - feat: New FBW Utils and Moderation bot (08/01/2024) diff --git a/src/commands/utils/vatsim/functions/vatsimEvents.ts b/src/commands/utils/vatsim/functions/vatsimEvents.ts index 97351cab..468c8f83 100644 --- a/src/commands/utils/vatsim/functions/vatsimEvents.ts +++ b/src/commands/utils/vatsim/functions/vatsimEvents.ts @@ -22,7 +22,7 @@ export async function handleVatsimEvents(interaction: ChatInputCommandInteractio .then((res) => res.json()) .then((res) => res.data) .then((res) => res.filter((event: { type: string; }) => event.type === 'Event')) - .then((res) => res.slice(0, 6)); + .then((res) => res.slice(0, 5)); const fields: EmbedField[] = eventsList.map((event: any) => { // eslint-disable-next-line camelcase diff --git a/src/events/contextInteractionHandler.ts b/src/events/contextInteractionHandler.ts index f2e6a9ca..d8afd555 100644 --- a/src/events/contextInteractionHandler.ts +++ b/src/events/contextInteractionHandler.ts @@ -1,4 +1,4 @@ -import { Color, ContextMenuCommand, event, Events, Reply } from '../lib'; +import { Color, ContextMenuCommand, event, Events, makeEmbed, Reply } from '../lib'; import contextArray from '../commands/context'; const contextMap = new Map( @@ -30,8 +30,16 @@ export default event(Events.InteractionCreate, async ({ log, client }, interacti await context.callback({ client, log, interaction }); } catch (error) { + const errorEmbed = makeEmbed({ + title: 'An error occurred while executing this context command.', + description: `${error}`, + color: Color.Error, + }); + log('[Context Error]', error); + await interaction.followUp({ embeds: [errorEmbed] }); + if (interaction.deferred || interaction.replied) { log('Interaction was already replied to or deferred, ignoring'); } diff --git a/src/events/slashCommandHandler.ts b/src/events/slashCommandHandler.ts index 4c880056..0d6edaf0 100644 --- a/src/events/slashCommandHandler.ts +++ b/src/events/slashCommandHandler.ts @@ -1,4 +1,4 @@ -import { Color, SlashCommand, event, Events, Reply } from '../lib'; +import { Color, SlashCommand, event, Events, Reply, makeEmbed } from '../lib'; import commandArray from '../commands'; /* eslint-disable no-underscore-dangle */ @@ -58,8 +58,16 @@ export default event(Events.InteractionCreate, async ({ log, client }, interacti await command.callback({ client, log, interaction }); } catch (error) { + const errorEmbed = makeEmbed({ + title: 'An error occurred while executing this command.', + description: `${error}`, + color: Color.Error, + }); + log('[Command Error]', error); + await interaction.followUp({ embeds: [errorEmbed] }); + if (interaction.deferred || interaction.replied) { log('Interaction was already replied to or deferred, ignoring'); }