From a26ce53508c950a3fd266909ac67efd156692739 Mon Sep 17 00:00:00 2001 From: KieranRobson Date: Sun, 26 Jun 2022 18:15:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Fix=20Paid=20Member=20Embed=20Wi?= =?UTF-8?q?thout=20Packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- events/interactionCreate.js | 62 ++++++++++++++++++++++---------- events/modalSubmitInteraction.js | 34 ------------------ 2 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 events/modalSubmitInteraction.js diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 64153a4..0e7581f 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,5 +1,6 @@ const client = require("../index"); +const discord = require("discord.js") client.on("interactionCreate", async (interaction) => { // Slash Command Handling @@ -49,26 +50,23 @@ client.on("interactionCreate", async (interaction) => { } else{ - const modal = new ModalBuilder() // We create a Modal - .setCustomId('modal-paidmember') - .setTitle('Paid Member Discord Access') - .addComponents( - new ModalField() + const modal = new discord.Modal() + .setCustomId('modal-paidmember') + .setTitle('Paid Member Discord Access') + const studentname = new discord.TextInputComponent() .setLabel("Student Name") - .setStyle("short") - .setMin(1) - .setPlaceholder("Joe Bloggs") - .setCustomId("studentname"), - new ModalField() + .setStyle("SHORT") + .setCustomId("studentname") + const studentnumber = new discord.TextInputComponent() .setLabel("Student Number") - .setStyle("short") + .setStyle("SHORT") .setCustomId("studentnumber") - .setMin(9) - .setMin(9) - .setPlaceholder("201801122") - ) - client.modal.open(interaction, modal) - } + const firstActionRow = new discord.MessageActionRow().addComponents(studentname); + const secondActionRow = new discord.MessageActionRow().addComponents(studentnumber); + modal.addComponents(firstActionRow, secondActionRow); + await interaction.showModal(modal); + + } } if(interaction.customId == "deletemessage") @@ -262,7 +260,33 @@ client.on("interactionCreate", async (interaction) => { await interaction.reply({ content: 'Roles have been updated', ephemeral: true}); } - - } + + if(interaction.isModalSubmit) + { + if(interaction.customId === 'modal-paidmember'){ + const execchannel = client.channels.cache.get('981678376655921153') + + const embed = new discord.MessageEmbed() + .setTitle("New Paid Member Request") + .setColor('GREEN') + .addField('Discord Tag', `${ interaction.user} <- Click to add role.`) + .addField('Student Name', `${ interaction.fields.getTextInputValue("studentname")}`) + .addField('Student Number',`${ interaction.fields.getTextInputValue("studentnumber")}`) + const row = new discord.MessageActionRow() + .addComponents( + new discord.MessageButton() + .setCustomId('deletemessage') + .setEmoji('') + .setLabel('Delete Message') + .setStyle('DANGER') + ) + execchannel.send({embeds: [embed], components: [row] }); + await interaction.deferReply({ ephemeral: true }) + interaction.followUp({ content: 'Your request has been sent to execs!', ephemeral: true }) + + } + } + + }); \ No newline at end of file diff --git a/events/modalSubmitInteraction.js b/events/modalSubmitInteraction.js deleted file mode 100644 index f3473c3..0000000 --- a/events/modalSubmitInteraction.js +++ /dev/null @@ -1,34 +0,0 @@ -const client = require("../index"); -const discord = require('discord.js'); - -client.on('modalSubmitInteraction', async (interaction) => { - if(interaction.customId === 'modal-paidmember'){ - const execchannel = client.channels.cache.get('974268736079015956') - - const embed = new discord.MessageEmbed() - .setTitle("New Paid Member Request") - .setColor('GREEN') - .addField('Discord Tag', `${ interaction.user}`) - .addField('Student Name', `${ interaction.fields.getTextInputValue("studentname")}`) - .addField('Student Number',`${ interaction.fields.getTextInputValue("studentnumber")}`) - const row = new discord.MessageActionRow() - .addComponents( - new discord.MessageButton() - .setCustomId('addrole') - .setEmoji('') - .setLabel('Add Role') - .setStyle('SUCCESS') - ) - .addComponents( - new discord.MessageButton() - .setCustomId('deletemessage') - .setEmoji('') - .setLabel('Delete Message') - .setStyle('DANGER') - ) - execchannel.send({embeds: [embed], components: [row] }); - await interaction.deferReply({ ephemeral: true }) - interaction.followUp({ content: 'Your request has been sent to execs!', ephemeral: true }) - - } -}); \ No newline at end of file