module.exports = { data: new SlashCommandBuilder() .setName("screenshot") .setDescription("Submit your screenshot") .addStringOption((option) => option .setName("nickname") .setDescription("Your Nickname to be displayed in the website") .setMinLength(3) .setMaxLength(350) .setRequired(true) ) .addAttachmentOption((option) => option .setName("image") .setDescription("Attach the screenshot") .setRequired(true) ) .addBooleanOption((option) => option .setName("secret") .setDescription("Whether or not the uploading should be ephemeral/secret.") ), async execute(interaction) { const username = interaction.options.getString("nickname"); //get nickname const imageurl = interaction.options.getAttachment("image"); //get imageurl const embed = new EmbedBuilder() .setDescription("``<<>>``") .setColor("#00b0f4") .setTimestamp(); await interaction.reply({ embeds: [embed], fetchReply: true, // ephemeral: true }); const exampleEmbed1 = new EmbedBuilder() .setDescription( "``<<>>``" ) .setThumbnail(`${imageurl.url}`) .setImage(`${imageurl.url}`) .setColor("#00b0f4") .setTimestamp(); const row = new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("accept") .setLabel("Accept") .setEmoji("✅") .setStyle("3"), new ButtonBuilder() .setCustomId("reject") .setLabel("Reject") .setEmoji("❌") .setStyle("1") ); interaction.editReply({ embeds: [exampleEmbed1], components: [row] }); // Filter the message to only listen to the user who sent the command const filter = (m) => console.log(m.author.id, interaction.user.id); // Collect Button Clicks const collector = interaction.channel.createMessageComponentCollector( filter, { max: 1, timer: 15000, } ); // Listen for Clicks on the interaction collector.on("collect", async (i) => { console.log(i); // for debugging only. // If Accept Button is Clicked if (i.customId === "accept") { // You can do your query here. const memberid = interaction.member.user.id; //get member id var sql1 = "INSERT INTO `screenshot` (`name`, `url`, `status`, `memebrid`) VALUES ('"+username+"','"+ imageurl.url+"', '1', '"+ memberid+"')"; con.query(sql1, function (err, result){ if(err) throw err; }) const exampleEmbed2 = new EmbedBuilder() .setDescription("``<<>>``") .setThumbnail(`${imageurl.url}`) .setImage(`${imageurl.url}`) .setColor("#00b0f4") .setTimestamp(); i.update({ embeds: [exampleEmbed2], components: [] }); } // If Reject Button is Clicked if (i.customId === "reject") { const exampleEmbed3 = new EmbedBuilder() .setDescription("``<<>>``") .setThumbnail(`${imageurl.url}`) .setImage(`${imageurl.url}`) .setColor("#00b0f4") .setTimestamp(); i.update({ embeds: [exampleEmbed3], components: [] }); } }); // End the listener after the time limit collector.on("end", (collected) => { console.log(`Collected ${collected.size} items`); }); }, };