Test improvements and dynamic modal labels

This commit is contained in:
Skylar Grant 2025-02-09 20:53:22 -05:00
parent 23c81305a0
commit 017eaddf9b
2 changed files with 35 additions and 17 deletions

View File

@ -639,7 +639,8 @@ const functions = {
}); });
}); });
}, },
oneFieldModal(templateId) { oneFieldModal(templateId, labels) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field:';
// Create the modal // Create the modal
const modal = new Modal() const modal = new Modal()
.setCustomId('oneFieldMemeModal') .setCustomId('oneFieldMemeModal')
@ -647,7 +648,7 @@ const functions = {
// Create the text input // Create the text input
const textInput = new TextInputComponent() const textInput = new TextInputComponent()
.setCustomId('memeTextField') .setCustomId('memeTextField')
.setLabel('Text Field:') .setLabel(fieldOneLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create and pre-fill a template ID field // Create and pre-fill a template ID field
const templateIdField = new TextInputComponent() const templateIdField = new TextInputComponent()
@ -661,7 +662,9 @@ const functions = {
modal.addComponents(textRow, templateIdRow); modal.addComponents(textRow, templateIdRow);
return modal; return modal;
}, },
twoFieldModal(templateId) { twoFieldModal(templateId, labels) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field 1:';
const fieldTwoLabel = labels[1] ? labels[1] : 'Text Field 2:';
// Create the modal // Create the modal
const modal = new Modal() const modal = new Modal()
.setCustomId('twoFieldMemeModal') .setCustomId('twoFieldMemeModal')
@ -669,12 +672,12 @@ const functions = {
// Create the first text input // Create the first text input
const fieldOneTextInput = new TextInputComponent() const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne') .setCustomId('memeTextFieldOne')
.setLabel('Text Field 1:') .setLabel(fieldOneLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the second text input // Create the second text input
const fieldTwoTextInput = new TextInputComponent() const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo') .setCustomId('memeTextFieldTwo')
.setLabel('Text Field 2:') .setLabel(fieldTwoLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create and pre-fill a template ID field // Create and pre-fill a template ID field
const templateIdField = new TextInputComponent() const templateIdField = new TextInputComponent()
@ -689,7 +692,10 @@ const functions = {
modal.addComponents(fieldOneRow, fieldTwoRow, templateIdRow); modal.addComponents(fieldOneRow, fieldTwoRow, templateIdRow);
return modal; return modal;
}, },
threeFieldModal(templateId) { threeFieldModal(templateId, labels) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field 1:';
const fieldTwoLabel = labels[1] ? labels[1] : 'Text Field 2:';
const fieldThreeLabel = labels[2] ? labels[2] : 'Text Field 3:';
// Create the modal // Create the modal
const modal = new Modal() const modal = new Modal()
.setCustomId('threeFieldMemeModal') .setCustomId('threeFieldMemeModal')
@ -697,17 +703,17 @@ const functions = {
// Create the first text input // Create the first text input
const fieldOneTextInput = new TextInputComponent() const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne') .setCustomId('memeTextFieldOne')
.setLabel('Text Field 1:') .setLabel(fieldOneLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the second text input // Create the second text input
const fieldTwoTextInput = new TextInputComponent() const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo') .setCustomId('memeTextFieldTwo')
.setLabel('Text Field 2:') .setLabel(fieldTwoLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the third text input // Create the third text input
const fieldThreeTextInput = new TextInputComponent() const fieldThreeTextInput = new TextInputComponent()
.setCustomId('memeTextFieldThree') .setCustomId('memeTextFieldThree')
.setLabel('Text Field 3:') .setLabel(fieldThreeLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create and pre-fill a template ID field // Create and pre-fill a template ID field
const templateIdField = new TextInputComponent() const templateIdField = new TextInputComponent()
@ -723,7 +729,11 @@ const functions = {
modal.addComponents(fieldOneRow, fieldTwoRow, fieldThreeRow, templateIdRow); modal.addComponents(fieldOneRow, fieldTwoRow, fieldThreeRow, templateIdRow);
return modal; return modal;
}, },
fourFieldModal(templateId) { fourFieldModal(templateId, labels) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field 1:';
const fieldTwoLabel = labels[1] ? labels[1] : 'Text Field 2:';
const fieldThreeLabel = labels[2] ? labels[2] : 'Text Field 3:';
const fieldFourLabel = labels[3] ? labels[3] : 'Text Field 4:';
// Create the modal // Create the modal
const modal = new Modal() const modal = new Modal()
.setCustomId('fourFieldMemeModal') .setCustomId('fourFieldMemeModal')
@ -731,22 +741,22 @@ const functions = {
// Create the first text input // Create the first text input
const fieldOneTextInput = new TextInputComponent() const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne') .setCustomId('memeTextFieldOne')
.setLabel('Text Field 1:') .setLabel(fieldOneLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the second text input // Create the second text input
const fieldTwoTextInput = new TextInputComponent() const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo') .setCustomId('memeTextFieldTwo')
.setLabel('Text Field 2:') .setLabel(fieldTwoLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the third text input // Create the third text input
const fieldThreeTextInput = new TextInputComponent() const fieldThreeTextInput = new TextInputComponent()
.setCustomId('memeTextFieldThree') .setCustomId('memeTextFieldThree')
.setLabel('Text Field 3:') .setLabel(fieldThreeLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create the fourth text input // Create the fourth text input
const fieldFourTextInput = new TextInputComponent() const fieldFourTextInput = new TextInputComponent()
.setCustomId('memeTextFieldFour') .setCustomId('memeTextFieldFour')
.setLabel('Text Field 4:') .setLabel(fieldFourLabel)
.setStyle('SHORT'); .setStyle('SHORT');
// Create and pre-fill a template ID field // Create and pre-fill a template ID field
const templateIdField = new TextInputComponent() const templateIdField = new TextInputComponent()

View File

@ -23,17 +23,25 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
try { try {
const template = interaction.options.getString('template'); const template = interaction.options.getString('template');
let memeModal;
// Switch the template // Switch the template
switch (template) { switch (template) {
// One-Field Memes // One-Field Memes
// Two-Field Memes // Two-Field Memes
case '181913649': // Y'all got any more of that case '181913649': // Y'all got any more of that
// Generate a modal with two text inputs
memeModal = fn.memes.twoFieldModal(template, ['Top Text', 'Bottom Text']);
await interaction.showModal(memeModal);
break;
case '124055727': // Drake Hotline Bling No/Yes case '124055727': // Drake Hotline Bling No/Yes
// Generate a modal with two text inputs
memeModal = fn.memes.twoFieldModal(template, ['Drake No', 'Drake Yes']);
await interaction.showModal(memeModal);
break;
case '217743513': // Uno Draw 25 case '217743513': // Uno Draw 25
// Generate a modal with two text inputs // Generate a modal with two text inputs
const twoFieldMemeModal = fn.memes.twoFieldModal(template); memeModal = fn.memes.twoFieldModal(template, ['<blank> or draw 25', 'Caption Above Person']);
await interaction.showModal(twoFieldMemeModal); await interaction.showModal(memeModal);
break; break;
// Three-Field Memes // Three-Field Memes
case '322841258': // Anakin & Padme case '322841258': // Anakin & Padme