import { EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder, Message, Client } from'discord.js'; module.exports = { aliases: ['embedcreate', 'createembed'], description: 'Crée un embed customisable', emote: '📝', utilisation: '', permission: 10, async execute(message: Message, args: string[], client: Client) { const embed = new EmbedBuilder(); const menu = new StringSelectMenuBuilder() .setCustomId('embed-options') .setPlaceholder('Select an option') .addOptions([ { label: '📝 Titre', value: 'title' }, { label: '📖 Description', value: 'description' }, { label: '🎨 Couleur', value: 'color' }, { label: '🖼️ Image URL', value: 'image' }, { label: '🖼️ Thumbnail URL', value: 'thumbnail' }, { label: '👤 Autheur', value: 'author' }, { label: '👣 Footer', value: 'footer' }, { label: '🚀 Envoyer', value: 'send' }, ]); const row: any = new ActionRowBuilder() .addComponents(menu); const selectMenuMessage = await message.channel.send({ content: `Veuillez sélectionner une option pour l'embed:`, components: [row] }); client.on('interactionCreate', async (interaction) => { if (!interaction.isStringSelectMenu()) return; if (interaction.customId === 'embed-options') { const selectedOption = interaction.values[0]; if (selectedOption === 'send') { await interaction.reply({ content: `Veuillez mentionner le salon où l'embed sera envoyé.`, fetchReply: true }); const channelFilter = (m: any) => m.author.id === interaction.user.id; if (!interaction.channel) return; const channelCollector = interaction.channel.createMessageCollector({ filter: channelFilter, max: 1, time: 60000 }); // 1 minute to reply channelCollector.on('collect', async (m) => { let channel: any = m.mentions.channels.first(); if (!channel) { const channelId = m.content; if (!interaction.guild) return; channel = interaction.guild.channels.cache.get(channelId); } if (!channel) { interaction.followUp({ content: 'Salon invalide.' }); return; } channel.send({ embeds: [embed] }); message.channel.send(`Embed correctement envoyé dans le channel <#${channel.id}>`) }); } else { const optionMessage = await interaction.reply({ content: `Veuillez entrer ${selectedOption} de l'embed:`, fetchReply: true }); const optionFilter = (m: any) => m.author.id === interaction.user.id; if (!interaction.channel) return; const optionCollector = interaction.channel.createMessageCollector({ filter: optionFilter, max: 1 }); optionCollector.on('collect', async (m) => { let optionValue: any = ''; if (m.content.toLowerCase() !== 'cancel') { optionValue = m.content; } optionMessage.delete(); m.delete(); switch (selectedOption) { case 'title': embed.setTitle(optionValue); break; case 'description': embed.setDescription(optionValue); break; case 'color': embed.setColor(optionValue); break; case 'image': embed.setImage(optionValue); break; case 'thumbnail': embed.setThumbnail(optionValue); break; case 'author': embed.setAuthor({ name: optionValue }); break; case 'footer': embed.setFooter({ text: optionValue }); break; } selectMenuMessage.edit({ embeds: [embed], components: [row] }); }); } } }); }, };