client.on('interactionCreate', async (interaction) => { if (interaction.isButton()) { // show modal if (interaction.customId === 'applymarketing') { const modal = new ModalBuilder() .setTitle('Marketing Application') .setCustomId('apply_market') const ageMkt = new TextInputBuilder() .setCustomId('staff_age_m') .setLabel("How old are you?") .setMinLength(1) .setMaxLength(3) .setStyle(TextInputStyle.Short) .setPlaceholder('19') .setRequired(true) const TzMkt = new TextInputBuilder() .setCustomId('staff_timezone_m') .setLabel("In what timezone are you located?") .setMaxLength(120) .setStyle(TextInputStyle.Short) .setPlaceholder(`GMT+1`) .setRequired(true) const DeskMkt = new TextInputBuilder() .setCustomId('desc_m') .setLabel("Do you have previous experience in marketing") .setMinLength(10) .setMaxLength(1024) .setStyle(TextInputStyle.Paragraph) .setPlaceholder(`I have...`) .setRequired(true) const MeanMkt = new TextInputBuilder() .setCustomId('mean_m') .setLabel("What does this role mean to you?") .setMinLength(10) .setMaxLength(1024) .setStyle(TextInputStyle.Paragraph) .setPlaceholder(`It means to me....`) .setRequired(true) const AbtMkt = new TextInputBuilder() .setCustomId('about_m') .setLabel("Tell us about yourself!") .setMinLength(10) .setMaxLength(1024) .setStyle(TextInputStyle.Paragraph) .setPlaceholder(`I'm...`) .setRequired(true) const rows = [ageMkt, TzMkt, DeskMkt, MeanMkt, AbtMkt].map( (component) => new ActionRowBuilder().addComponents(component) ) modal.addComponents(...rows); interaction.showModal(modal); // end of modal } // Accept and deny buttons if (interaction.customId === 'staff_accept_market') { // TODO: save user id in json or sum instead of getting id from embed footer const getIdFromFooter = interaction.message.embeds[0].footer.text; const getMemberMkt = await interaction.guild.members.fetch(getIdFromFooter); await getMemberMkt.roles.add(config.staffRoles).catch((err) => { console.error(err) return interaction.reply({ content: ":x: There was an error when a try to add roles for the user." }) }); interaction.reply({ content: `✅ Added hired role for **${getMemberMkt.user.username}**, Accepted into Marketing by ${interaction.user.username}. Ensure you send a welcome message in , <#1027258849306083439> and purged the channel. User has been notified to check the channel.` }) await getMemberMkt.send({ content: `Hey ${getMemberMkt.user.username}, You've been accepted into the Specian Marketing team! We've sent a message in <#1027258849306083439> to start the onboarding process.` }).catch(() => { return interaction.message.reply(':x: Unable to message this user. Possible users DMs are turned off.') }) const newDisabledRow = new ActionRowBuilder() .setComponents( new ButtonBuilder() .setCustomId('staff_accept_marketing_end') .setDisabled() .setEmoji("1024329283499474964") .setStyle(ButtonStyle.Secondary) .setLabel('Accept') ) .addComponents( new ButtonBuilder() .setCustomId('staff_deny_ended_marketing') .setDisabled() .setEmoji("1024242630332252170") .setStyle(ButtonStyle.Secondary) .setLabel('Deny') ) interaction.message.edit({ components: [newDisabledRow] }) } if (interaction.customId === 'staff_deny_market') { // TODO: save user id in json or sum instead of getting id from embed footer const getIdFromFooter = interaction.message.embeds[0].footer?.text; const getMemberMkt = await interaction.guild.members.fetch(getIdFromFooter); await getMemberMkt.send({ content: `Hey ${getMemberMkt.user.tag} We've reviewed your application and have unfortunately decided we're not ready to have you join the team. You may re-apply 60 days from your original application date.` }).catch(e => {}) interaction.reply({ content: `<:no:1024242630332252170> ${getMemberMkt.user.tag} has been rejected by ${interaction.user.tag}.` }) const newDisabledRow = new ActionRowBuilder() .setComponents( new ButtonBuilder() .setCustomId('staff_accept_marketing_end') .setDisabled() .setEmoji("1024329283499474964") .setStyle(ButtonStyle.Secondary) .setLabel('Accept') ) .addComponents( new ButtonBuilder() .setCustomId('staff_deny_ended_marketing') .setDisabled() .setEmoji("1024242630332252170") .setStyle(ButtonStyle.Secondary) .setLabel('Deny') ) interaction.message.edit({ components: [newDisabledRow] }) } } if (interaction.isModalSubmit()) { if (interaction.customId === 'applymarketing') { const MktstaffAge = interaction.fields.getTextInputValue('staff_age_m'); const staffTz = interaction.fields.getTextInputValue('staff_timezone_m'); const MarketDesc = interaction.fields.getTextInputValue('desc_m'); const MarketMean = interaction.fields.getTextInputValue('mean_m'); const AboutM = interaction.fields.getTextInputValue('about_m'); if (isNaN(MktstaffAge)) { return interaction.reply({ content: "<:no:1024242630332252170> Your age must be a number, please resend the form.", ephemeral: true }) } client.users.send(interaction.user.id, "Your application has been submitted sucesfully.") interaction.reply({ content: '<:yesspecian:1024329283499474964> Your staff application has been submit successfully.', ephemeral: true }) const staffSubmitChannel = interaction.guild.channels.cache.get(config.submitChannel); if (!staffSubmitChannel) return; const embed = new EmbedBuilder() .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() }) .setTitle("Marketing staff application") .setColor('Blue') .setTimestamp() .setFooter({ text: interaction.user.id }) .setThumbnail(interaction.user.displayAvatarURL()) .addFields( { name: "How old are you?", value: MktstaffAge }, { name: "In what timezone are you located?", value: staffTz }, { name: "Do you have previous experience in marketing", value: MarketDesc }, { name: "What does this role mean to you?", value: MarketMean }, { name: "Tell us about yourself!", value: AboutM } ) const row = new ActionRowBuilder() .setComponents( new ButtonBuilder() .setCustomId('staff_accept_market') .setDisabled() .setEmoji("1024329283499474964") .setStyle(ButtonStyle.Secondary) .setLabel('Accept') ) .addComponents( new ButtonBuilder() .setCustomId('staff_deny_market') .setDisabled() .setEmoji("1024242630332252170") .setStyle(ButtonStyle.Secondary) .setLabel('Deny') ) staffSubmitChannel.send({ embeds: [embed], components: [row] }) } } })