Move custom activity modal fields to eventUtils for use in the editing step
This commit is contained in:
parent
2a6fbdbf6c
commit
12bb1f614e
|
@ -1,16 +1,12 @@
|
||||||
import { Bot, Interaction, InteractionResponseTypes, MessageComponentTypes, TextStyles } from '../../../deps.ts';
|
import { Bot, Interaction, InteractionResponseTypes } from '../../../deps.ts';
|
||||||
import { deleteTokenEarly } from '../tokenCleanup.ts';
|
import { deleteTokenEarly } from '../tokenCleanup.ts';
|
||||||
import { idSeparator, pathIdxSeparator } from '../eventUtils.ts';
|
import { generateCustomActivityFields, idSeparator, pathIdxSeparator } from '../eventUtils.ts';
|
||||||
import { customId as verifyCustomActivityId } from './step1b-verifyCustomActivity.ts';
|
import { customId as verifyCustomActivityId } from './step1b-verifyCustomActivity.ts';
|
||||||
import utils from '../../utils.ts';
|
import utils from '../../utils.ts';
|
||||||
import { dbClient, queries } from '../../db.ts';
|
import { dbClient, queries } from '../../db.ts';
|
||||||
|
|
||||||
export const customId = 'customAct';
|
export const customId = 'customAct';
|
||||||
|
|
||||||
export const activityTitleId = 'activityTitle';
|
|
||||||
export const activitySubtitleId = 'activitySubtitle';
|
|
||||||
export const activityMaxPlayersId = 'activityMaxPlayers';
|
|
||||||
|
|
||||||
const execute = async (bot: Bot, interaction: Interaction) => {
|
const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
if (interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId) {
|
if (interaction.data?.customId && interaction.member && interaction.guildId && interaction.channelId) {
|
||||||
// Light Telemetry
|
// Light Telemetry
|
||||||
|
@ -24,43 +20,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||||
data: {
|
data: {
|
||||||
title: 'Create Custom Activity',
|
title: 'Create Custom Activity',
|
||||||
customId: verifyCustomActivityId,
|
customId: verifyCustomActivityId,
|
||||||
components: [{
|
components: generateCustomActivityFields(actTitle, actSubtitle, activityMaxPlayers),
|
||||||
type: MessageComponentTypes.ActionRow,
|
|
||||||
components: [{
|
|
||||||
type: MessageComponentTypes.InputText,
|
|
||||||
customId: activityTitleId,
|
|
||||||
label: 'Activity Title:',
|
|
||||||
placeholder: 'The name of the game or event.',
|
|
||||||
style: TextStyles.Short,
|
|
||||||
minLength: 1,
|
|
||||||
maxLength: 35,
|
|
||||||
value: actTitle || undefined,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
type: MessageComponentTypes.ActionRow,
|
|
||||||
components: [{
|
|
||||||
type: MessageComponentTypes.InputText,
|
|
||||||
customId: activitySubtitleId,
|
|
||||||
label: 'Activity Subtitle:',
|
|
||||||
placeholder: 'The specific activity within the game or event.',
|
|
||||||
style: TextStyles.Short,
|
|
||||||
minLength: 1,
|
|
||||||
maxLength: 50,
|
|
||||||
value: actSubtitle || undefined,
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
type: MessageComponentTypes.ActionRow,
|
|
||||||
components: [{
|
|
||||||
type: MessageComponentTypes.InputText,
|
|
||||||
customId: activityMaxPlayersId,
|
|
||||||
label: 'Maximum Players:',
|
|
||||||
placeholder: 'Please enter a number between 1 and 99.',
|
|
||||||
style: TextStyles.Short,
|
|
||||||
minLength: 1,
|
|
||||||
maxLength: 2,
|
|
||||||
value: activityMaxPlayers || undefined,
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
},
|
},
|
||||||
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1a-openCustomModal.ts:modal', interaction, e));
|
}).catch((e: Error) => utils.commonLoggers.interactionSendError('step1a-openCustomModal.ts:modal', interaction, e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import config from '../../../config.ts';
|
import config from '../../../config.ts';
|
||||||
import { ApplicationCommandFlags, Bot, ButtonStyles, Interaction, InteractionResponseTypes, MessageComponentTypes } from '../../../deps.ts';
|
import { ApplicationCommandFlags, Bot, ButtonStyles, Interaction, InteractionResponseTypes, MessageComponentTypes } from '../../../deps.ts';
|
||||||
import { failColor, infoColor1, safelyDismissMsg, somethingWentWrong } from '../../commandUtils.ts';
|
import { failColor, infoColor1, safelyDismissMsg, somethingWentWrong } from '../../commandUtils.ts';
|
||||||
import { idSeparator, pathIdxEnder, pathIdxSeparator } from '../eventUtils.ts';
|
import { activityMaxPlayersId, activitySubtitleId, activityTitleId, idSeparator, pathIdxEnder, pathIdxSeparator } from '../eventUtils.ts';
|
||||||
import { addTokenToMap, selfDestructMessage } from '../tokenCleanup.ts';
|
import { addTokenToMap, selfDestructMessage } from '../tokenCleanup.ts';
|
||||||
import { activityMaxPlayersId, activitySubtitleId, activityTitleId } from './step1a-openCustomModal.ts';
|
|
||||||
import { customId as gameSelectionId } from './step1-gameSelection.ts';
|
import { customId as gameSelectionId } from './step1-gameSelection.ts';
|
||||||
import { customId as openCustomModalId } from './step1a-openCustomModal.ts';
|
import { customId as openCustomModalId } from './step1a-openCustomModal.ts';
|
||||||
import utils from '../../utils.ts';
|
import utils from '../../utils.ts';
|
||||||
|
|
|
@ -91,3 +91,44 @@ export const dateTimeFields = (prefillTime = '', prefillTimeZone = '', prefillDa
|
||||||
value: prefillDate || undefined,
|
value: prefillDate || undefined,
|
||||||
}],
|
}],
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
export const activityTitleId = 'activityTitle';
|
||||||
|
export const activitySubtitleId = 'activitySubtitle';
|
||||||
|
export const activityMaxPlayersId = 'activityMaxPlayers';
|
||||||
|
export const generateCustomActivityFields = (actTitle = '', actSubtitle = '', activityMaxPlayers = ''): ActionRow[] => [{
|
||||||
|
type: MessageComponentTypes.ActionRow,
|
||||||
|
components: [{
|
||||||
|
type: MessageComponentTypes.InputText,
|
||||||
|
customId: activityTitleId,
|
||||||
|
label: 'Activity Title:',
|
||||||
|
placeholder: 'The name of the game or event.',
|
||||||
|
style: TextStyles.Short,
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 35,
|
||||||
|
value: actTitle || undefined,
|
||||||
|
}],
|
||||||
|
}, {
|
||||||
|
type: MessageComponentTypes.ActionRow,
|
||||||
|
components: [{
|
||||||
|
type: MessageComponentTypes.InputText,
|
||||||
|
customId: activitySubtitleId,
|
||||||
|
label: 'Activity Subtitle:',
|
||||||
|
placeholder: 'The specific activity within the game or event.',
|
||||||
|
style: TextStyles.Short,
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 50,
|
||||||
|
value: actSubtitle || undefined,
|
||||||
|
}],
|
||||||
|
}, {
|
||||||
|
type: MessageComponentTypes.ActionRow,
|
||||||
|
components: [{
|
||||||
|
type: MessageComponentTypes.InputText,
|
||||||
|
customId: activityMaxPlayersId,
|
||||||
|
label: 'Maximum Players:',
|
||||||
|
placeholder: 'Please enter a number between 1 and 99.',
|
||||||
|
style: TextStyles.Short,
|
||||||
|
minLength: 1,
|
||||||
|
maxLength: 2,
|
||||||
|
value: activityMaxPlayers || undefined,
|
||||||
|
}],
|
||||||
|
}];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Bot, BotWithCache, Interaction, log, LT } from '../../deps.ts';
|
import { Bot, BotWithCache, Interaction, log, LT } from '../../deps.ts';
|
||||||
import { buttons } from '../buttons/_index.ts';
|
import { buttons } from '../buttons/_index.ts';
|
||||||
import { commands } from '../commands/_index.ts';
|
import { commands } from '../commands/_index.ts';
|
||||||
import { idSeparator, fillerChar } from '../buttons/eventUtils.ts';
|
import { fillerChar, idSeparator } from '../buttons/eventUtils.ts';
|
||||||
|
|
||||||
const commandNames: Array<string> = commands.map((command) => command.details.name);
|
const commandNames: Array<string> = commands.map((command) => command.details.name);
|
||||||
const buttonNames: Array<string> = buttons.map((button) => button.customId);
|
const buttonNames: Array<string> = buttons.map((button) => button.customId);
|
||||||
|
|
Loading…
Reference in New Issue