const { Client, Intents, MessageEmbed, Collection, MessageAttachment, MessageButton, MessageActionRow, Modal, TextInputComponent } = require('discord.js'); const fs = require('fs'); const sharp = require('sharp'); const config = require('./config.json') const client = new Client({ intents: Object.values(Intents.FLAGS) }); client.commands = new Collection(); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); for (const file of commandFiles) { const command = require(`./commands/${file}`); client.commands.set(command.data.name, command); } client.on('ready', () => { console.log(`Slash commandok betöltve!`); client.application.commands.set(client.commands.map(cmd => cmd.data)); }); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const { commandName } = interaction; const command = client.commands.get(commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ content: "hiba a parancsban", ephemeral: true }); } }); client.on('ready', () => { console.clear() console.log('tojásnak szóló üzenet, elindult a cucc') }) client.on('guildMemberAdd', async (member) => { if (member.guild.id !== '1307085169877975120') return; // Check for the specific server if (member.user.bot) return; const welcomeChannel = client.channels.cache.get('1307419314143629442'); // Corrected: Use member.guild instead of client.guild const autorole = member.guild.roles.cache.get('1307098025528791050'); // Assign the role member.roles.add(autorole); const fetch = (await import('node-fetch')).default; const avatarUrl = member.user.displayAvatarURL({ format: 'png', size: 128 }); const avatarResponse = await fetch(avatarUrl); const avatarBuffer = await avatarResponse.buffer(); const width = 700; const height = 250; const resizedAvatarBuffer = await sharp(avatarBuffer).resize(128, 128).toBuffer(); const realUserCount = member.guild.members.cache.filter(member => !member.user.bot).size; const welcomeImage = await sharp({ create: { width: width, height: height, channels: 4, background: { r: 0, g: 183, b: 255, alpha: 1 } } }) .composite([ { input: resizedAvatarBuffer, top: 25, left: 25, blend: 'over' }, { input: Buffer.from(` Üdvözöljük, ${member.user.username}! Te vagy a ${realUserCount}. tag a szerveren! `), top: 0, left: 0, blend: 'over' } ]) .png() .toBuffer(); // Embed létrehozása const embed = new MessageEmbed() .setColor('#00B7FF') .setTitle(`Szia, ${member.user.username}!`) .setDescription(`Érezd jól magad!`) .setImage('attachment://welcome-image.png'); // Kép küldése const attachment = new MessageAttachment(welcomeImage, 'welcome-image.png'); welcomeChannel.send({ embeds: [embed], files: [attachment] }); }); client.on('messageCreate', async (message) => { if (message.author.bot || !message.guild) return; if (message.member.permissions.has("ADMINISTRATOR")) { const ticketChannel = client.channels.cache.get('1307095364079190056'); const tgfChannel = client.channels.cache.get('1317854025038954576'); if(message.content == 'hfkaSFHIHaskif28fhasif2asfÐ?DS:As') { const ticketEmbed = new MessageEmbed() .setTitle('Szia!') .setDescription('Ticket nyitás dolog') .setColor('#00B7FF'); const openButton = new MessageButton() .setCustomId('open_ticket') .setLabel('Ticket nyitása') .setStyle('PRIMARY') .setEmoji('🎫'); const ticketRow = new MessageActionRow() .addComponents(openButton); ticketChannel.send({content: '@everyone', embeds: [ticketEmbed], components: [ticketRow] }); const tgfEmbed = new MessageEmbed() .setTitle('Tagfelvétel dolog') .setDescription('Jelentkezhetsz devnek és buildernek') .setColor('#00B7FF'); const builderButton = new MessageButton() .setCustomId('builder_tgf') .setLabel('Builder jelentkezés') .setStyle('PRIMARY') .setEmoji('👷‍♂️'); const devButton = new MessageButton() .setCustomId('dev_tgf') .setLabel('Developer jelentkezés') .setStyle('PRIMARY') .setEmoji('👨‍💻') const tgfRow = new MessageActionRow() .addComponents(builderButton, devButton) tgfChannel.send({content: '@everyone', embed: [tgfEmbed], components: [tgfRow] }); await message.delete(); } } }); client.on('interactionCreate', async (interaction) => { if (interaction.isButton()) { if (interaction.customId === 'builder_tgf') { const modal = new Modal() .setCustomId('builder_modal') .setTitle('Builder jelentkezési lap'); const q1 = new TextInputComponent() .setCustomId('builder_modal_q1') .setLabel('Hány éves vagy?') .setStyle('SHORT'); const q2 = new TextInputComponent() .setCustomId('builder_modal_q2') .setLabel('Voltál-e már más szerveren builder?') .setStyle('SHORT'); const q3 = new TextInputComponent() .setCustomId('builder_modal_q3') .setLabel('Milyen tematikákban szoktál építeni?') .setStyle('PARAGRAPH'); const q4 = new TextInputComponent() .setCustomId('builder_modal_q4') .setLabel('Vannak az építményeidről fotók?') .setStyle('SHORT'); const q1row = new MessageActionRow().addComponents(q1); const q2row = new MessageActionRow().addComponents(q2); const q3row = new MessageActionRow().addComponents(q3); const q4row = new MessageActionRow().addComponents(q4); modal.addComponents(q1row, q2row, q3row, q4row) await interaction.showModal(modal); } else if (interaction.customId === 'dev_tgf') { const modal = new Modal() .setCustomId('dev_modal') .setTitle('Developer jelentkezési lap'); const q1 = new TextInputComponent() .setCustomId('dev_modal_q1') .setLabel('Hány éves vagy?') .setStyle('SHORT'); const q2 = new TextInputComponent() .setCustomId('dev_modal_q2') .setLabel('Tudsz-e plugint írni?') .setStyle('SHORT'); const q3 = new TextInputComponent() .setCustomId('dev_modal_q3') .setLabel('Értesz-e a különbözó plugin configokhoz?') .setStyle('SHORT'); const q4 = new TextInputComponent() .setCustomId('dev_modal_q4') .setLabel('Voltál-e már más szerveren dev?') .setStyle('SHORT'); const q5 = new TextInputComponent() .setCustomId('dev_modal_q5') .setLabel('Mit tennél hozzá a szerverhez?') .setStyle('PARAGRAPH'); const q1row = new MessageActionRow().addComponents(q1); const q2row = new MessageActionRow().addComponents(q2); const q3row = new MessageActionRow().addComponents(q3); const q4row = new MessageActionRow().addComponents(q4); const q5row = new MessageActionRow().addComponents(q5); modal.addComponents(q1row, q2row, q3row, q4row, q5row) await interaction.showModal(modal); } else if (interaction.customId === 'open_ticket') { const guildName = 'Clench Network'; const guild = client.guilds.cache.find(guild => guild.name === guildName); const ticketCategoryName = 'tickets'; const ticketCategory = guild.channels.cache.find(channel => channel.type === 'GUILD_CATEGORY' && channel.name === ticketCategoryName); // Helyettesítsd be a megfelelő kategória azonosítóval const channel = await interaction.guild.channels.create(`ticket-${interaction.user.username}`, { type: 'text', parent: ticketCategory, permissionOverwrites: [ { id: interaction.guild.id, deny: ['VIEW_CHANNEL'], }, { id: interaction.user.id, allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'], }, ], }); const embed = new MessageEmbed() .setTitle('Szia, ' + interaction.user.username + '!') .setDescription('Kérlek, írd le, miért nyitottad a ticketet.') .setColor('#00B7FF'); const closeButton = new MessageButton() .setCustomId('close_ticket') .setLabel('🔒 Lezárás') .setStyle('DANGER'); channel.send({ content: `<@${interaction.user.id}>`, embeds: [embed], components: [new MessageActionRow().addComponents(closeButton)] }); await interaction.reply({ content: 'A ticket sikeresen megnyitva!', ephemeral: true }); } else if (interaction.customId === 'close_ticket') { interaction.channel.delete(); } } else if (interaction.isModalSubmit()) { if (interaction.customId === 'builder_modal') { const a1 = interaction.fields.getTextInputValue('builder_modal_q1'); const a2 = interaction.fields.getTextInputValue('builder_modal_q2'); const a3 = interaction.fields.getTextInputValue('builder_modal_q3'); const a4 = interaction.fields.getTextInputValue('builder_modal_q4'); const embed = new MessageEmbed() .setColor('#00B7FF') .setTitle(`${interaction.user.tag} jelentkezett Buildernek`) .setDescription(`Izé dolgok:`) .addField(`Életkora:`, a1) .addField(`Volt-e már buider:`, a2) .addField(`Ilyen témákban épít:`, a3) .addField(`Vannak-e építményeiről fotók:`, a4); const tgfReqsChannel = client.channels.cache.get('1317938861174947912'); tgfReqsChannel.send({ embeds: [embed] }); interaction.reply({ content: "Jelentkezés sikeresen elküldve!", ephemeral: true }); } else if (interaction.customId === 'dev_modal') { const a1 = interaction.fields.getTextInputValue('dev_modal_q1'); const a2 = interaction.fields.getTextInputValue('dev_modal_q2'); const a3 = interaction.fields.getTextInputValue('dev_modal_q3'); const a4 = interaction.fields.getTextInputValue('dev_modal_q4'); const a5 = interaction.fields.getTextInputValue('dev_modal_q5'); const embed = new MessageEmbed() .setColor('#00B7FF') .setTitle(`${interaction.user.tag} jelentkezett Developernek`) .setDescription(`Izé dolgok:`) .addField(`Életkora:`, a1) .addField(`Tud-e plugint írni:`, a2) .addField(`Ért-e a különböző plugin configokhoz?`, a3) .addField(`Volt-e már dev:`, a4) .addField(`Ezt tenné hozzá a szerverhez:`, a5); const tgfReqsChannel = client.channels.cache.get('1317938861174947912'); tgfReqsChannel.send({ embeds: [embed] }); interaction.reply({ content: "Jelentkezés sikeresen elküldve!", ephemeral: true }); } } }); client.login(config.token);