const { Client, GatewayIntentBits, Permissions, MessageActionRow, MessageButton, ButtonStyle, MessageEmbed, EmbedBuilder, ButtonBuilder, ActionRowBuilder, SlashCommandBuilder, PermissionsBitField, StringSelectMenuBuilder, ChannelType, PermissionFlagsBits, ModalBuilder, CommandInteraction } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent,] }); const fs = require('fs'); const token = ''; // Sostituisci con il tuo token const prefix = '/'; // Prefisso dei comandi const welcomeChannelID = ''; // Sostituisci con l'ID del canale di benvenuto const modLogChannelID = ''; // Sostituisci con l'ID del canale di moderazione const staffRoleID = ''; // Sostituisci con l'ID del ruolo dello staff client.on('ready', () => { console.log(`Il bot è online come ${client.user.tag}`); }); client.on('guildMemberAdd', async (member) => { const welcomeChannelID = await client.channels.fetch(''); //ID const roleID = ''; // Sostituisci con l'ID del ruolo base nel server member.roles.add(roleID); if (welcomeChannelID) { const welcomeEmbed = new EmbedBuilder() .setColor('#e3c57b') .setTitle('Benvenuto/a!') .setDescription(`Benvenuto/a su ${member.guild.name}, ${member}!`) .setThumbnail(member.user.displayAvatarURL().toString()) //url here .addFields( { name: '*Questo è* ', value: '*un server senza topic specifico, aperto a tutto e tutti e con poche ed essenziali regole basate sul buon senso.*' }, { name: '\u200B', value: '\u200B' }, { name: 'Visita Info', value: '↑', inline: true }, { name: 'Visita Annunci', value: '↑', inline: true }, { name: 'Visita Roles', value: '↑', inline: true } ) .setImage('') //Here the URL is for a large image .setTimestamp() .setFooter({ text: 'Mini Community', iconURL: '' }); welcomeChannelID.send({ embeds: [welcomeEmbed] }); } }); function logBan(member, executor, reason) { const modLogChannel = client.channels.cache.get(modLogChannelID); if (modLogChannel) { const logMessage = `${executor.tag} ha bannato ${member.user.tag} per il motivo: ${reason}`; modLogChannel.send(logMessage); } } client.on('messageCreate', async (message) => { if (message.author.bot) return; if (message.content.startsWith(prefix)) { const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command === 'clear') { if (!args[0]) return message.reply('Specifica la quantità di messaggi da cancellare.'); const amount = parseInt(args[0]) + 1; if (isNaN(amount)) return message.reply('La quantità specificata non è valida.'); message.channel.bulkDelete(amount, true).catch((err) => { console.error(err); message.channel.send('Si è verificato un errore durante la cancellazione dei messaggi.'); }); console.log('Comando clear eseguito!'); } const wordsToFilter = ['word', 'word', 'word', 'word', 'word', 'word']; for (const word of wordsToFilter) { if (message.content.toLowerCase().includes(word)) { message.delete(); message.reply('Il tuo messaggio contiene una parola vietata.'); message.member.ban({ reason: 'Parola vietata nel messaggio' }) .then((member) => { message.channel.send(`${member.user.tag} è stato bannato per utilizzo di parole vietate.`); logBan(member, message.author, 'Parola vietata nel messaggio'); }) .catch((error) => console.error(error)); break; } } } if (message.content.startsWith(`${prefix}ticket`)) { const member = message.guild.members.cache.get(message.author.id); const roleID = ''; if (!member.roles.cache.has(roleID)) { return message.reply('Non puoi eseguire questo comando!'); } } }); //Ticket Script const tickets = new Map(); client.on('ready', async () => { const guildId = ''; // Sostituisci con l'ID del tuo server const channelId = ''; // Sostituisci con l'ID del canale dei ticket const channel = client.channels.cache.get(channelId); // Cancella i messaggi dei ticket esistenti solo se ci sono dei messaggi const existingMessages = await channel.messages.fetch({ limit: 10 }); if (existingMessages.size > 0) { existingMessages.forEach(async (message) => { await message.delete(); }); } const embed = new EmbedBuilder() .setTitle('Ticket per Supporto') .setDescription('Crea un Ticket e contatta i nostri Responsabili o Staff premendo il pulsante qua sotto') .setColor('#e3c57b') .setImage(''); // Sostituisci con l'URL dell'immagine che desideri includere const ticketBtn = new ButtonBuilder() .setCustomId('ticketBtn') .setLabel('Crea Ticket') .setEmoji('🎫') .setStyle(ButtonStyle.Secondary); const row = new ActionRowBuilder().addComponents(ticketBtn); channel.send({ embeds: [embed], components: [row] }); }); client.on('interactionCreate', async (interaction) => { if (!interaction.isButton()) return; const { customId, user, guild } = interaction; if (customId === 'ticketBtn') { const row = new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId('closeTicket') .setLabel('Chiudi Ticket') .setStyle(ButtonStyle.Secondary) ); const embed = new EmbedBuilder() .setTitle('Ticket Aperto') .setDescription('Il tuo ticket è stato aperto. Attendi il supporto dello staff.') .setColor('#e3c57b') .addFields({ name: 'User', value: user.tag }) .setImage('') // Sostituisci con l'URL dell'immagine che desideri includere .setTimestamp(); const channel = await guild.channels.create(`${user.username || 'utente'}-ticket`, { type: 'text', parent: '', permissionOverwrites: [ { id: guild.id, deny: [Permissions.ViewChannel], }, { id: user.id, allow: [Permissions.ViewChannel], }, { id: '', // Ruolo Staff allow: [Permissions.ViewChannel], }, ], }); const closeButton = new ButtonBuilder() .setCustomId('closeTicket') .setLabel('Chiudi Ticket') .setStyle(ButtonStyle.Secondary); const pingButton = new ButtonBuilder() .setCustomId('pingStaff') .setLabel('Ping Staff') .setStyle(ButtonStyle.Secondary); row.addComponents(closeButton, pingButton); await channel.send({ embeds: [embed], components: [row] }); await interaction.reply({ content: `${user.tag}, il tuo ticket è stato creato con successo! Puoi vederlo qui ${channel}`, ephemeral: true, }); tickets.set(user.id, channel.id); } else if (customId === 'closeTicket') { const channelId = tickets.get(user.id); if (channelId) { const channel = await guild.channels.fetch(channelId); await channel.delete(); const dmEmbed = new EmbedBuilder() .setTitle('Ticket Chiuso') .setDescription('Grazie per aver aperto un ticket. Il tuo ticket è stato chiuso. Se hai bisogno di altro, premi pure il pulsante qua sotto.') .setColor('#e3c57b') .setImage('') // Sostituisci con l'URL dell'immagine che desideri includere .setTimestamp() .setFooter(`Inviato da ${guild.name}`); const dmButton = new ButtonBuilder() .setLabel('Ritorna Indietro') .setStyle(ButtonStyle.Link) .setURL('https://discord.com/channels/991321696420245544/1202011962058215424'); const dmRow = new ActionRowBuilder().addComponents(dmButton); await user.send({ embeds: [dmEmbed], components: [dmRow] }); tickets.delete(user.id); } } else if (customId === 'pingStaff') { const staffRoleId = ''; const staffRole = guild.roles.cache.get(staffRoleId); if (staffRole) { await interaction.reply({ content: `Hai pingato con successo lo staff: ${staffRole.toString()}!`, ephemeral: true, }); } } }); client.login(token);