Misc cleanup/organization

This commit is contained in:
Ean Milligan (Bastion) 2023-04-26 06:50:26 -04:00
parent 75aeda6195
commit 1f1460f553
8 changed files with 13 additions and 10 deletions

View File

@ -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';

View File

@ -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<string, string> = new Map();
for (const row of interaction.data.components) {

View File

@ -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<string, string> = 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}`);

View File

@ -106,11 +106,13 @@ export const generateLFGButtons = (whitelist: boolean): [ButtonComponent, Button
},
}];
export const generateTimeFieldStr = (eventDateTimeStr: string, eventDateTime: Date) => `${eventDateTimeStr}\n<t:${Math.floor(eventDateTime.getTime() / 1000)}:R>`;
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<t:${Math.floor(eventDateTime.getTime() / 1000)}:R>`,
value: generateTimeFieldStr(eventDateTimeStr, eventDateTime),
inline: true,
}, {
name: 'Add to Calendar:',

View File

@ -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<LFGMember>, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`;

View File

@ -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));

View File

@ -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: [{

View File

@ -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}`);
}
};