client.on('interactionCreate', async (interaction) => { if (!interaction.isButton()) return; if (interaction.customId === 'appealBanButton') { const appealEmbed = new MessageEmbed() .setColor('#ff0000') .setTitle(' Ban Appeal') .setDescription('Sei stato bannato dal server. Se desideri fare appello al tuo ban, per favore compilare il modulo qui sotto.') .addFields( { name: 'Perché ritieni di essere stato bannato?', value: 'Rispondi qui...', inline: false }, { name: 'Il tuo ID Discord', value: 'Inserisci qui...', inline: false } ); const appealRow = new MessageActionRow() .addComponents( new MessageButton() .setCustomId('submitAppealButton') .setLabel('Invia Appello') .setStyle('PRIMARY') ); await interaction.reply({ content: 'Ecco il modulo di appello:', embeds: [appealEmbed], components: [appealRow], ephemeral: true }); } if (interaction.customId === 'submitAppealButton') { const originalMessage = await interaction.deferred.fetch(); const { fields } = originalMessage.embeds[0]; const reason = fields[0].value; const discordId = fields[1].value; const user = interaction.user; const appealEmbed = new MessageEmbed() .setColor('#0099ff') .setTitle('Nuovo Appello Ban') .addFields( { name: 'Utente', value: `${user.tag} (${user.id})` }, { name: 'ID Utente', value: `\`${discordId}\`` }, { name: 'Motivo del Ban', value: `\`${reason}\`` } ) .setTimestamp(); const acceptButton = new MessageButton() .setCustomId('acceptAppealButton') .setLabel('Accetta') .setStyle('SUCCESS'); const rejectButton = new MessageButton() .setCustomId('rejectAppealButton') .setLabel('Rifiuta') .setStyle('DANGER'); const appealRow = new MessageActionRow() .addComponents(acceptButton, rejectButton); const appealChannel = client.channels.cache.get('1253280758643036251'); if (appealChannel) { appealChannel.send({ content: `<@${user.id}> ha fatto un appello ban:`, embeds: [appealEmbed], components: [appealRow] }); } await interaction.reply({ content: 'Grazie per aver inviato il modulo di appello. Il nostro team lo esaminerà a breve.', ephemeral: true }); } if (interaction.customId === 'acceptAppealButton' || interaction.customId === 'rejectAppealButton') { const message = interaction.message; const userId = message.embeds[0].fields.find(field => field.name === 'ID Utente').value.replace(/\`/g, ''); const user = await client.users.fetch(userId); if (interaction.customId === 'acceptAppealButton') { const guild = interaction.guild; await guild.members.unban(userId); const invite = await guild.channels.cache.get('1118825505303576587').createInvite({ maxAge: 0, maxUses: 1 }); await user.send(`Il tuo appello ban è stato accettato. Ecco un invito per rientrare nel server: ${invite}`); await interaction.reply({ content: `Appello ban di ${user.tag} accettato e l'utente è stato sbannato.`, ephemeral: true }); } else if (interaction.customId === 'rejectAppealButton') { await user.send('Il tuo appello ban è stato rifiutato. Per ulteriori informazioni, contatta vdevhd.exe.'); await interaction.reply({ content: `Appello ban di ${user.tag} rifiutato.`, ephemeral: true }); } } });