From 1f1460f553a8313518821bd8a5e550f5b2abc598 Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Wed, 26 Apr 2023 06:50:26 -0400 Subject: [PATCH] Misc cleanup/organization --- src/buttons/event-creation/step1-gameSelection.ts | 2 +- src/buttons/event-creation/step1b-verifyCustomActivity.ts | 2 +- src/buttons/event-creation/step2-finalize.ts | 6 +++--- src/buttons/event-creation/utils.ts | 6 ++++-- src/buttons/eventUtils.ts | 1 + src/buttons/live-event/deleteConfirmed.ts | 2 +- src/commands/setup.ts | 2 +- src/events/interactionCreate.ts | 2 +- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/buttons/event-creation/step1-gameSelection.ts b/src/buttons/event-creation/step1-gameSelection.ts index e2c4794..415d7e0 100644 --- a/src/buttons/event-creation/step1-gameSelection.ts +++ b/src/buttons/event-creation/step1-gameSelection.ts @@ -1,4 +1,4 @@ -import { ActionRow, ApplicationCommandFlags, ApplicationCommandTypes, Bot, ButtonStyles, Interaction, InteractionResponseTypes, MessageComponentTypes, TextStyles } from '../../../deps.ts'; +import { ActionRow, ApplicationCommandFlags, ApplicationCommandTypes, Bot, ButtonStyles, Interaction, InteractionResponseTypes, MessageComponentTypes } from '../../../deps.ts'; import { infoColor1, somethingWentWrong } from '../../commandUtils.ts'; import { CommandDetails } from '../../types/commandTypes.ts'; import { Activities } from './activities.ts'; diff --git a/src/buttons/event-creation/step1b-verifyCustomActivity.ts b/src/buttons/event-creation/step1b-verifyCustomActivity.ts index 08adc59..36e64a0 100644 --- a/src/buttons/event-creation/step1b-verifyCustomActivity.ts +++ b/src/buttons/event-creation/step1b-verifyCustomActivity.ts @@ -11,7 +11,7 @@ import utils from '../../utils.ts'; export const customId = 'verifyCustomActivity'; const execute = async (bot: Bot, interaction: Interaction) => { - if (interaction?.data?.components?.length && interaction.guildId && interaction.channelId && interaction.member) { + if (interaction.data?.components?.length && interaction.guildId && interaction.channelId && interaction.member) { // Parse out our data const tempDataMap: Map = new Map(); for (const row of interaction.data.components) { diff --git a/src/buttons/event-creation/step2-finalize.ts b/src/buttons/event-creation/step2-finalize.ts index 5f68d8b..5da3e15 100644 --- a/src/buttons/event-creation/step2-finalize.ts +++ b/src/buttons/event-creation/step2-finalize.ts @@ -1,7 +1,7 @@ import { Bot, Interaction } from '../../../deps.ts'; import { somethingWentWrong } from '../../commandUtils.ts'; import { createLFGPost, getFinalActivity } from './utils.ts'; -import { eventDateId, eventDescriptionId, eventTimeId, eventTimeZoneId, idSeparator, pathIdxSeparator } from '../eventUtils.ts'; +import { eventDateId, eventDescriptionId, eventTimeId, eventTimeZoneId, idSeparator, noDescProvided, pathIdxSeparator } from '../eventUtils.ts'; import { addTokenToMap } from '../tokenCleanup.ts'; import { Activities, Activity } from './activities.ts'; import { getDateFromRawInput } from './dateTimeUtils.ts'; @@ -10,7 +10,7 @@ import utils from '../../utils.ts'; export const customId = 'finalize'; const execute = async (bot: Bot, interaction: Interaction) => { - if (interaction?.data?.components?.length && interaction.guildId && interaction.channelId && interaction.member && interaction.member.user) { + if (interaction.data?.components?.length && interaction.guildId && interaction.channelId && interaction.member && interaction.member.user) { const tempDataMap: Map = new Map(); for (const row of interaction.data.components) { if (row.components?.[0]) { @@ -45,7 +45,7 @@ const execute = async (bot: Bot, interaction: Interaction) => { const rawEventTime = tempDataMap.get(eventTimeId) || ''; const rawEventTimeZone = tempDataMap.get(eventTimeZoneId) || ''; const rawEventDate = tempDataMap.get(eventDateId) || ''; - const eventDescription = tempDataMap.get(eventDescriptionId) || 'No description provided.'; + const eventDescription = tempDataMap.get(eventDescriptionId) || noDescProvided; if (!rawEventTime || !rawEventTimeZone || !rawEventDate) { // Error out if user somehow failed to provide one of the fields (eventDescription is allowed to be null/empty) somethingWentWrong(bot, interaction, `missingFieldFromEventDescription@${rawEventTime}_${rawEventTimeZone}_${rawEventDate}`); diff --git a/src/buttons/event-creation/utils.ts b/src/buttons/event-creation/utils.ts index 9f21bc0..c3a66cc 100644 --- a/src/buttons/event-creation/utils.ts +++ b/src/buttons/event-creation/utils.ts @@ -106,11 +106,13 @@ export const generateLFGButtons = (whitelist: boolean): [ButtonComponent, Button }, }]; +export const generateTimeFieldStr = (eventDateTimeStr: string, eventDateTime: Date) => `${eventDateTimeStr}\n`; + export const createLFGPost = ( category: string, activity: Activity, eventDateTime: Date, - eventDateTimeStr: String, + eventDateTimeStr: string, eventDescription: string, authorId: bigint, author: string, @@ -138,7 +140,7 @@ export const createLFGPost = ( inline: true, }, { name: lfgStartTimeName, - value: `${eventDateTimeStr}\n`, + value: generateTimeFieldStr(eventDateTimeStr, eventDateTime), inline: true, }, { name: 'Add to Calendar:', diff --git a/src/buttons/eventUtils.ts b/src/buttons/eventUtils.ts index 84e91d0..c665f62 100644 --- a/src/buttons/eventUtils.ts +++ b/src/buttons/eventUtils.ts @@ -22,6 +22,7 @@ export const joinEventBtnStr = 'Join'; export const requestToJoinEventBtnStr = 'Request to Join'; export const leaveEventBtnStr = 'Leave'; export const alternateEventBtnStr = 'Join as Alternate'; +export const noDescProvided = 'No description provided.'; // Member List generators export const generateMemberTitle = (memberList: Array, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`; diff --git a/src/buttons/live-event/deleteConfirmed.ts b/src/buttons/live-event/deleteConfirmed.ts index 4d11ac4..0c653d9 100644 --- a/src/buttons/live-event/deleteConfirmed.ts +++ b/src/buttons/live-event/deleteConfirmed.ts @@ -10,7 +10,7 @@ export const confirmedCustomId = 'confirmedCustomId'; export const confirmStr = 'yes'; const execute = async (bot: Bot, interaction: Interaction) => { - if (interaction?.data?.customId && interaction?.data?.components?.length && interaction.channelId && interaction.guildId && interaction.member && interaction.member.user) { + if (interaction.data?.customId && interaction.data?.components?.length && interaction.channelId && interaction.guildId && interaction.member && interaction.member.user) { // Light Telemetry dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e)); diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 8164638..0894648 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -275,7 +275,7 @@ The Discord Slash Command system will ensure you provide all the required detail content: `Welcome to <#${interaction.channelId}>, managed by <@${botId}>!`, embeds: [{ title: `To get started, click on the '${createNewEventBtn}' button below!`, - color: successColor, + color: infoColor2, fields: introFields, }], components: [{ diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index 586690c..c11b5ae 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -23,6 +23,6 @@ export const interactionCreate = (rawBot: Bot, interaction: Interaction) => { return; } - log(LT.WARN, `interaction NOT HANDLED!!! customId: ${interaction.data.customId} name: ${interaction.data.name}`); + log(LT.WARN, `UNHANDLED INTERACTION!!! customId: ${interaction.data.customId} name: ${interaction.data.name}`); } };