Added modal to gather student forum
parent
f16b53e495
commit
9060b591bb
|
@ -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] })
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
})
|
|
@ -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 })
|
||||
|
||||
}
|
||||
});
|
4
index.js
4
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
|
||||
|
|
Loading…
Reference in New Issue