Added dynamic labels and default values.
All checks were successful
NodBot PE Dockerization / build (push) Successful in 9s

This commit is contained in:
Skylar Grant 2025-02-09 21:12:27 -05:00
parent 017eaddf9b
commit 80c23ca7db
2 changed files with 49 additions and 21 deletions

View File

@ -639,8 +639,9 @@ const functions = {
});
});
},
oneFieldModal(templateId, labels) {
oneFieldModal(templateId, labels, values) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field:';
const fieldOneValue = values[0] ? values[0] : '';
// Create the modal
const modal = new Modal()
.setCustomId('oneFieldMemeModal')
@ -649,22 +650,25 @@ const functions = {
const textInput = new TextInputComponent()
.setCustomId('memeTextField')
.setLabel(fieldOneLabel)
.setValue(fieldOneValue)
.setStyle('SHORT');
// Create and pre-fill a template ID field
const templateIdField = new TextInputComponent()
.setCustomId('memeTemplateId')
.setLabel('Template ID: (advanced)')
.setStyle('SHORT')
.setValue(templateId);
.setValue(templateId)
.setStyle('SHORT');
// Add the components to the modal
const textRow = new MessageActionRow().addComponents(textInput);
const templateIdRow = new MessageActionRow().addComponents(templateIdField);
modal.addComponents(textRow, templateIdRow);
return modal;
},
twoFieldModal(templateId, labels) {
twoFieldModal(templateId, labels, values) {
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field 1:';
const fieldTwoLabel = labels[1] ? labels[1] : 'Text Field 2:';
const fieldOneValue = values[0] ? values[0] : '';
const fieldTwoValue = values[1] ? values[1] : '';
// Create the modal
const modal = new Modal()
.setCustomId('twoFieldMemeModal')
@ -673,18 +677,20 @@ const functions = {
const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne')
.setLabel(fieldOneLabel)
.setValue(fieldOneValue)
.setStyle('SHORT');
// Create the second text input
const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo')
.setLabel(fieldTwoLabel)
.setValue(fieldTwoValue)
.setStyle('SHORT');
// Create and pre-fill a template ID field
const templateIdField = new TextInputComponent()
.setCustomId('memeTemplateId')
.setLabel('Template ID: (advanced)')
.setStyle('SHORT')
.setValue(templateId);
.setValue(templateId)
.setStyle('SHORT');
// Add the components to the modal
const fieldOneRow = new MessageActionRow().addComponents(fieldOneTextInput);
const fieldTwoRow = new MessageActionRow().addComponents(fieldTwoTextInput);
@ -692,10 +698,13 @@ const functions = {
modal.addComponents(fieldOneRow, fieldTwoRow, templateIdRow);
return modal;
},
threeFieldModal(templateId, labels) {
threeFieldModal(templateId, labels, values) {
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 fieldOneValue = values[0] ? values[0] : '';
const fieldTwoValue = values[1] ? values[1] : '';
const fieldThreeValue = values[2] ? values[2] : '';
// Create the modal
const modal = new Modal()
.setCustomId('threeFieldMemeModal')
@ -704,23 +713,26 @@ const functions = {
const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne')
.setLabel(fieldOneLabel)
.setValue(fieldOneValue)
.setStyle('SHORT');
// Create the second text input
const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo')
.setLabel(fieldTwoLabel)
.setValue(fieldTwoValue)
.setStyle('SHORT');
// Create the third text input
const fieldThreeTextInput = new TextInputComponent()
.setCustomId('memeTextFieldThree')
.setLabel(fieldThreeLabel)
.setValue(fieldThreeValue)
.setStyle('SHORT');
// Create and pre-fill a template ID field
const templateIdField = new TextInputComponent()
.setCustomId('memeTemplateId')
.setLabel('Template ID: (advanced)')
.setStyle('SHORT')
.setValue(templateId);
.setValue(templateId)
.setStyle('SHORT');
// Add the components to the modal
const fieldOneRow = new MessageActionRow().addComponents(fieldOneTextInput);
const fieldTwoRow = new MessageActionRow().addComponents(fieldTwoTextInput);
@ -729,11 +741,15 @@ const functions = {
modal.addComponents(fieldOneRow, fieldTwoRow, fieldThreeRow, templateIdRow);
return modal;
},
fourFieldModal(templateId, labels) {
fourFieldModal(templateId, labels, values) {
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:';
const fieldOneValue = values[0] ? values[0] : '';
const fieldTwoValue = values[1] ? values[1] : '';
const fieldThreeValue = values[2] ? values[2] : '';
const fieldFourValue = values[3] ? values[3] : '';
// Create the modal
const modal = new Modal()
.setCustomId('fourFieldMemeModal')
@ -742,28 +758,32 @@ const functions = {
const fieldOneTextInput = new TextInputComponent()
.setCustomId('memeTextFieldOne')
.setLabel(fieldOneLabel)
.setValue(fieldOneValue)
.setStyle('SHORT');
// Create the second text input
const fieldTwoTextInput = new TextInputComponent()
.setCustomId('memeTextFieldTwo')
.setLabel(fieldTwoLabel)
.setValue(fieldTwoValue)
.setStyle('SHORT');
// Create the third text input
const fieldThreeTextInput = new TextInputComponent()
.setCustomId('memeTextFieldThree')
.setLabel(fieldThreeLabel)
.setValue(fieldThreeValue)
.setStyle('SHORT');
// Create the fourth text input
const fieldFourTextInput = new TextInputComponent()
.setCustomId('memeTextFieldFour')
.setLabel(fieldFourLabel)
.setValue(fieldFourValue)
.setStyle('SHORT');
// Create and pre-fill a template ID field
const templateIdField = new TextInputComponent()
.setCustomId('memeTemplateId')
.setLabel('Template ID: (advanced)')
.setStyle('SHORT')
.setValue(templateId);
.setValue(templateId)
.setStyle('SHORT');
// Add the components to the modal
const fieldOneRow = new MessageActionRow().addComponents(fieldOneTextInput);
const fieldTwoRow = new MessageActionRow().addComponents(fieldTwoTextInput);

View File

@ -28,29 +28,37 @@ module.exports = {
switch (template) {
// One-Field Memes
// Two-Field Memes
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 '181913649': // Drake Hotline Bling
// Generate a modal with two text inputs
memeModal = fn.memes.twoFieldModal(template, ['Drake No', 'Drake Yes']);
await interaction.showModal(memeModal);
break;
case '124055727': // Y'all Got Any More...
// Generate a modal with two text inputs
memeModal = fn.memes.twoFieldModal(template, ['Top', 'Bottom Text'], ['Y\'all got any more of ', '']);
await interaction.showModal(memeModal);
break;
case '217743513': // Uno Draw 25
// Generate a modal with two text inputs
memeModal = fn.memes.twoFieldModal(template, ['<blank> or draw 25', 'Caption Above Person']);
memeModal = fn.memes.twoFieldModal(template, ['<blank> or draw 25', 'Caption Above Person'], ['', 'Me']);
await interaction.showModal(memeModal);
break;
// Three-Field Memes
case '322841258': // Anakin & Padme
// Generate a modal with three text inputs
memeModal = fn.memes.threeFieldModal(template, ['Anakin', 'Padme', 'Padme'], ['', '', 'Right?']);
await interaction.showModal(memeModal);
break;
case '342785297': // We are not the same
// Generate a modal with three text inputs
memeModal = fn.memes.threeFieldModal(template, ['You...', 'I...', 'We...'], ['', '', 'We are not the same.']);
await interaction.showModal(memeModal);
break;
case '155067746': // Surprised Pikachu
case '87743020': // Two Buttons
// Generate a modal with three text inputs
const threeFieldMemeModal = fn.memes.threeFieldModal(template);
await interaction.showModal(threeFieldMemeModal);
memeModal = fn.memes.threeFieldModal(template, ['Button 1', 'Button 2', 'Person Caption']);
await interaction.showModal(memeModal);
break;
default:
await interaction.reply('Invalid meme template');