diff --git a/commands/embeds/paidmember.js b/commands/embeds/paidmember.js index 9ce054c..8e56a45 100644 --- a/commands/embeds/paidmember.js +++ b/commands/embeds/paidmember.js @@ -1,8 +1,8 @@ const discord = require("discord.js"); -const { Modal } = require('discord-modals') // Modal class +const { Modal, TextInputComponent, showModal } = require('discord-modals') // Modal class module.exports = { - name: "welcome", + name: "paidmember", aliases: [''], /** * @@ -23,10 +23,10 @@ module.exports = { const row = new discord.MessageActionRow() .addComponents( new discord.MessageButton() - .setURL('https://github.com/hullcss/conduct/') - .setEmoji('') + .setCustomId('paidModal') + .setEmoji('💲') .setLabel('Code of Conduct') - .setStyle('LINK') + .setStyle('PRIMARY') ) message.channel.send({ embeds: [embed], components: [row] }) }, diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 15400a0..b3286bd 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,5 +1,6 @@ const client = require("../index"); +const { DiscordModal, ModalBuilder, ModalField } = require('discord-modal') // Modal and TextInputComponent class client.on("interactionCreate", async (interaction) => { // Slash Command Handling @@ -34,12 +35,33 @@ client.on("interactionCreate", async (interaction) => { // Context Menu Handling if (interaction.isButton()) { - interaction.member.roles.add("973646380771979304") - await interaction.reply({ content: 'Roles have been updated', ephemeral: true}); + if(interaction.customId == "codeOfConduct"){ + interaction.member.roles.add("973646380771979304") + await interaction.reply({ content: 'Roles have been updated', ephemeral: true}); + } + + if(interaction.customId == "paidModal") + { + const modal = new ModalBuilder() // We create a Modal + .setCustomId('modal-paidmember') + .setTitle('Paid Member Discord Access') + .addComponents( + new ModalField() + .setLabel("Student Name") + .setStyle("short") + .setMin(1) + .setPlaceholder("Joe Bloggs") + .setCustomId("studentname"), + new ModalField() + .setLabel("Student Number") + .setStyle("short") + .setCustomId("studentnumber") + .setMin(9) + .setMin(9) + .setPlaceholder("201801122") + ) + client.modal.open(interaction, modal) + } } - - - - -}) \ No newline at end of file + }) \ No newline at end of file diff --git a/events/modalSubmitInteraction.js b/events/modalSubmitInteraction.js new file mode 100644 index 0000000..5250677 --- /dev/null +++ b/events/modalSubmitInteraction.js @@ -0,0 +1,19 @@ +const client = require("../index"); +const discord = require('discord.js'); + +client.on('modalSubmitInteraction', async (interaction) => { + if(interaction.customId === 'modal-paidmember'){ + const channel = client.channels.cache.get('970027557607071754') + + 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")}`) + channel.send({content: '<@427866208726155274>', embeds: [embed] }); + 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/index.js b/index.js index 2032d36..3a9142c 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const config = require("./config.json"); const { Client, Collection } = require("discord.js"); -const discordModals = require('discord-modals') +const DiscordModal = require('discord-modal') const client = new Client({ intents: 32767, }); @@ -9,7 +9,7 @@ module.exports = client; // Global Variables client.commands = new Collection(); client.slashCommands = new Collection(); -discordModals(client); +DiscordModal(client) //client.config = require("./config.json"); // Initializing the project