const { MessageEmbed, MessageButton, MessageActionRow } = require('discord.js'); const SlashCommand = require('../../lib/SlashCommand'); const changelog = require('../../database/changelogSchema'); const { time } = require("@discordjs/builders"); const { Modal, TextInputComponent } = require("discord.js"); const command = new SlashCommand() .setName('newchangelog') .setDescription('Send a message to the changelog') .ownerOnly() .setRun(async (client, interaction, options) => { const date = new Date() const timeString = time(date) const relative = time(date, 'F') const modal = new Modal() .setCustomId('myModal') .setTitle('Changelog ') const messageInput = new TextInputComponent() .setCustomId('messageInput') .setLabel("Changelog text") .setStyle('PARAGRAPH'); const typeInput = new TextInputComponent() .setCustomId('TypeInput') .setLabel("Changelog Type") .setStyle('SHORT') .setPlaceholder('Types: Bug Fix, Feature, Added, Removed, Changed'); const firstActionRow = new MessageActionRow().addComponents(messageInput); const secondActionRow = new MessageActionRow().addComponents(typeInput); modal.addComponents(firstActionRow, secondActionRow); const message = interaction.fields.getTextInputValue('messageInput'); const type = interaction.fields.getTextInputValue('typeInput'); const CP = await changelog.findOne({ ident: "counter", }); const date2 = new Date().toLocaleDateString(); try { if (CP) await CP.update({ changelog: { message }, date: `${date2}`, type: { type } }) client.warn("[Manager] Updated Quadro's changelog.") interaction.reply({ embeds: [ new MessageEmbed() .setTitle("Updated changelog!") .addFields( { name: "Message", value: message }, { name: "Type", value: type }, { name: "Date", value: date2 } ) .setColor(client.config.embedColor) ], ephemeral: true }) await interaction.showModal(modal); } catch (error) { client.error(error) } }); module.exports = command;