Misc cleanup/organization
This commit is contained in:
parent
75aeda6195
commit
1f1460f553
|
@ -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 { infoColor1, somethingWentWrong } from '../../commandUtils.ts';
|
||||||
import { CommandDetails } from '../../types/commandTypes.ts';
|
import { CommandDetails } from '../../types/commandTypes.ts';
|
||||||
import { Activities } from './activities.ts';
|
import { Activities } from './activities.ts';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import utils from '../../utils.ts';
|
||||||
export const customId = 'verifyCustomActivity';
|
export const customId = 'verifyCustomActivity';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
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
|
// Parse out our data
|
||||||
const tempDataMap: Map<string, string> = new Map();
|
const tempDataMap: Map<string, string> = new Map();
|
||||||
for (const row of interaction.data.components) {
|
for (const row of interaction.data.components) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Bot, Interaction } from '../../../deps.ts';
|
import { Bot, Interaction } from '../../../deps.ts';
|
||||||
import { somethingWentWrong } from '../../commandUtils.ts';
|
import { somethingWentWrong } from '../../commandUtils.ts';
|
||||||
import { createLFGPost, getFinalActivity } from './utils.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 { addTokenToMap } from '../tokenCleanup.ts';
|
||||||
import { Activities, Activity } from './activities.ts';
|
import { Activities, Activity } from './activities.ts';
|
||||||
import { getDateFromRawInput } from './dateTimeUtils.ts';
|
import { getDateFromRawInput } from './dateTimeUtils.ts';
|
||||||
|
@ -10,7 +10,7 @@ import utils from '../../utils.ts';
|
||||||
export const customId = 'finalize';
|
export const customId = 'finalize';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
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();
|
const tempDataMap: Map<string, string> = new Map();
|
||||||
for (const row of interaction.data.components) {
|
for (const row of interaction.data.components) {
|
||||||
if (row.components?.[0]) {
|
if (row.components?.[0]) {
|
||||||
|
@ -45,7 +45,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
const rawEventTime = tempDataMap.get(eventTimeId) || '';
|
const rawEventTime = tempDataMap.get(eventTimeId) || '';
|
||||||
const rawEventTimeZone = tempDataMap.get(eventTimeZoneId) || '';
|
const rawEventTimeZone = tempDataMap.get(eventTimeZoneId) || '';
|
||||||
const rawEventDate = tempDataMap.get(eventDateId) || '';
|
const rawEventDate = tempDataMap.get(eventDateId) || '';
|
||||||
const eventDescription = tempDataMap.get(eventDescriptionId) || 'No description provided.';
|
const eventDescription = tempDataMap.get(eventDescriptionId) || noDescProvided;
|
||||||
if (!rawEventTime || !rawEventTimeZone || !rawEventDate) {
|
if (!rawEventTime || !rawEventTimeZone || !rawEventDate) {
|
||||||
// Error out if user somehow failed to provide one of the fields (eventDescription is allowed to be null/empty)
|
// 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}`);
|
somethingWentWrong(bot, interaction, `missingFieldFromEventDescription@${rawEventTime}_${rawEventTimeZone}_${rawEventDate}`);
|
||||||
|
|
|
@ -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 = (
|
export const createLFGPost = (
|
||||||
category: string,
|
category: string,
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
eventDateTime: Date,
|
eventDateTime: Date,
|
||||||
eventDateTimeStr: String,
|
eventDateTimeStr: string,
|
||||||
eventDescription: string,
|
eventDescription: string,
|
||||||
authorId: bigint,
|
authorId: bigint,
|
||||||
author: string,
|
author: string,
|
||||||
|
@ -138,7 +140,7 @@ export const createLFGPost = (
|
||||||
inline: true,
|
inline: true,
|
||||||
}, {
|
}, {
|
||||||
name: lfgStartTimeName,
|
name: lfgStartTimeName,
|
||||||
value: `${eventDateTimeStr}\n<t:${Math.floor(eventDateTime.getTime() / 1000)}:R>`,
|
value: generateTimeFieldStr(eventDateTimeStr, eventDateTime),
|
||||||
inline: true,
|
inline: true,
|
||||||
}, {
|
}, {
|
||||||
name: 'Add to Calendar:',
|
name: 'Add to Calendar:',
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const joinEventBtnStr = 'Join';
|
||||||
export const requestToJoinEventBtnStr = 'Request to Join';
|
export const requestToJoinEventBtnStr = 'Request to Join';
|
||||||
export const leaveEventBtnStr = 'Leave';
|
export const leaveEventBtnStr = 'Leave';
|
||||||
export const alternateEventBtnStr = 'Join as Alternate';
|
export const alternateEventBtnStr = 'Join as Alternate';
|
||||||
|
export const noDescProvided = 'No description provided.';
|
||||||
|
|
||||||
// Member List generators
|
// Member List generators
|
||||||
export const generateMemberTitle = (memberList: Array<LFGMember>, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`;
|
export const generateMemberTitle = (memberList: Array<LFGMember>, maxMembers: number): string => `Members Joined: ${memberList.length}/${maxMembers}`;
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const confirmedCustomId = 'confirmedCustomId';
|
||||||
export const confirmStr = 'yes';
|
export const confirmStr = 'yes';
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
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
|
// Light Telemetry
|
||||||
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
dbClient.execute(queries.callIncCnt('btn-confirmDelEvent')).catch((e) => utils.commonLoggers.dbError('deleteConfirmed.ts@incCnt', 'call sproc INC_CNT on', e));
|
||||||
|
|
||||||
|
|
|
@ -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}>!`,
|
content: `Welcome to <#${interaction.channelId}>, managed by <@${botId}>!`,
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: `To get started, click on the '${createNewEventBtn}' button below!`,
|
title: `To get started, click on the '${createNewEventBtn}' button below!`,
|
||||||
color: successColor,
|
color: infoColor2,
|
||||||
fields: introFields,
|
fields: introFields,
|
||||||
}],
|
}],
|
||||||
components: [{
|
components: [{
|
||||||
|
|
|
@ -23,6 +23,6 @@ export const interactionCreate = (rawBot: Bot, interaction: Interaction) => {
|
||||||
return;
|
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}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue