Test improvements and dynamic modal labels
This commit is contained in:
parent
23c81305a0
commit
017eaddf9b
38
functions.js
38
functions.js
@ -639,7 +639,8 @@ const functions = {
|
||||
});
|
||||
});
|
||||
},
|
||||
oneFieldModal(templateId) {
|
||||
oneFieldModal(templateId, labels) {
|
||||
const fieldOneLabel = labels[0] ? labels[0] : 'Text Field:';
|
||||
// Create the modal
|
||||
const modal = new Modal()
|
||||
.setCustomId('oneFieldMemeModal')
|
||||
@ -647,7 +648,7 @@ const functions = {
|
||||
// Create the text input
|
||||
const textInput = new TextInputComponent()
|
||||
.setCustomId('memeTextField')
|
||||
.setLabel('Text Field:')
|
||||
.setLabel(fieldOneLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create and pre-fill a template ID field
|
||||
const templateIdField = new TextInputComponent()
|
||||
@ -661,7 +662,9 @@ const functions = {
|
||||
modal.addComponents(textRow, templateIdRow);
|
||||
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
|
||||
const modal = new Modal()
|
||||
.setCustomId('twoFieldMemeModal')
|
||||
@ -669,12 +672,12 @@ const functions = {
|
||||
// Create the first text input
|
||||
const fieldOneTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldOne')
|
||||
.setLabel('Text Field 1:')
|
||||
.setLabel(fieldOneLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the second text input
|
||||
const fieldTwoTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldTwo')
|
||||
.setLabel('Text Field 2:')
|
||||
.setLabel(fieldTwoLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create and pre-fill a template ID field
|
||||
const templateIdField = new TextInputComponent()
|
||||
@ -689,7 +692,10 @@ const functions = {
|
||||
modal.addComponents(fieldOneRow, fieldTwoRow, templateIdRow);
|
||||
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
|
||||
const modal = new Modal()
|
||||
.setCustomId('threeFieldMemeModal')
|
||||
@ -697,17 +703,17 @@ const functions = {
|
||||
// Create the first text input
|
||||
const fieldOneTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldOne')
|
||||
.setLabel('Text Field 1:')
|
||||
.setLabel(fieldOneLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the second text input
|
||||
const fieldTwoTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldTwo')
|
||||
.setLabel('Text Field 2:')
|
||||
.setLabel(fieldTwoLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the third text input
|
||||
const fieldThreeTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldThree')
|
||||
.setLabel('Text Field 3:')
|
||||
.setLabel(fieldThreeLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create and pre-fill a template ID field
|
||||
const templateIdField = new TextInputComponent()
|
||||
@ -723,7 +729,11 @@ const functions = {
|
||||
modal.addComponents(fieldOneRow, fieldTwoRow, fieldThreeRow, templateIdRow);
|
||||
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
|
||||
const modal = new Modal()
|
||||
.setCustomId('fourFieldMemeModal')
|
||||
@ -731,22 +741,22 @@ const functions = {
|
||||
// Create the first text input
|
||||
const fieldOneTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldOne')
|
||||
.setLabel('Text Field 1:')
|
||||
.setLabel(fieldOneLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the second text input
|
||||
const fieldTwoTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldTwo')
|
||||
.setLabel('Text Field 2:')
|
||||
.setLabel(fieldTwoLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the third text input
|
||||
const fieldThreeTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldThree')
|
||||
.setLabel('Text Field 3:')
|
||||
.setLabel(fieldThreeLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create the fourth text input
|
||||
const fieldFourTextInput = new TextInputComponent()
|
||||
.setCustomId('memeTextFieldFour')
|
||||
.setLabel('Text Field 4:')
|
||||
.setLabel(fieldFourLabel)
|
||||
.setStyle('SHORT');
|
||||
// Create and pre-fill a template ID field
|
||||
const templateIdField = new TextInputComponent()
|
||||
|
||||
@ -23,17 +23,25 @@ module.exports = {
|
||||
async execute(interaction) {
|
||||
try {
|
||||
const template = interaction.options.getString('template');
|
||||
|
||||
let memeModal;
|
||||
// Switch the template
|
||||
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
|
||||
// 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
|
||||
// Generate a modal with two text inputs
|
||||
const twoFieldMemeModal = fn.memes.twoFieldModal(template);
|
||||
await interaction.showModal(twoFieldMemeModal);
|
||||
memeModal = fn.memes.twoFieldModal(template, ['<blank> or draw 25', 'Caption Above Person']);
|
||||
await interaction.showModal(memeModal);
|
||||
break;
|
||||
// Three-Field Memes
|
||||
case '322841258': // Anakin & Padme
|
||||
|
||||
Loading…
Reference in New Issue
Block a user