const { SlashCommandBuilder, ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); const fs = require('fs'); const path = require('path'); // Configuration const ALLOWED_CHANNEL_ID = '1354951205180150004'; module.exports = { data: new SlashCommandBuilder() .setName('aipost') .setDescription('Generate an Instagram post from a news article'), async execute(interaction) { // Check if the command is used in the allowed channel if (interaction.channelId !== ALLOWED_CHANNEL_ID) { return await interaction.reply({ content: 'This command can only be used in the designated channel.', ephemeral: true, }); } // Modal creation const modal = new ModalBuilder() .setCustomId('aipostModal') .setTitle('News Link'); // Text input component const newsLinkInput = new TextInputBuilder() .setCustomId('newsLinkInput') .setLabel('Please provide the news article URL') .setStyle(TextInputStyle.Short) .setPlaceholder('https://example.com/news-article') .setRequired(true); // Add text input to the modal const firstActionRow = new ActionRowBuilder().addComponents(newsLinkInput); modal.addComponents(firstActionRow); // Make the modal visible to the user await interaction.showModal(modal); }, // Handle the modal submission async modalSubmit(interaction) { if (interaction.customId === 'aipostModal') { // Acknowledge the interaction await interaction.deferReply(); // Placeholder for AI post generation await interaction.editReply({ content: 'Here is your generated Instagram post:\n\n' + '📸 *[Generated Image Placeholder]*\n\n' + '📝 **Generated Caption:**\n' + 'Exciting news in tech! 🚀\n' + 'Stay updated with the latest trends!\n\n' + '#tech #innovation #news #trending #instagram', }); } }, };