const { Client, Intents, MessageEmbed, MessageActionRow, MessageSelectMenu, MessageButton } = require('discord.js'); const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.GUILD_PRESENCES, ] }); const token = 'MTE1MDQ0OTUyODI0ODQ2NzUxNw.Gn-Msg.y25q6OJT66FVKbHSNNrr7eLW9dKKsibo3OYURU'; // Lembre-se de substituir pelo seu próprio token client.once('ready', () => { console.log(`Bot está conectado como ${client.user.tag}`); }); const usedCommandRecently = new Set(); client.on('messageCreate', async (message) => { if (message.content === '!ticket' && !usedCommandRecently.has(message.author.id)) { console.log(`Comando ticket chamado pelo usuário ${message.author.tag}`); // Adiciona o usuário à lista de utilizadores recentes usedCommandRecently.add(message.author.id); // Remove o utilizador da lista após 60 segundos setTimeout(() => { usedCommandRecently.delete(message.author.id); }, 60000); const embed = new MessageEmbed() .setTitle('Estúdio Lux 🔥 #50') .setDescription(' | **Viu algum produto em nosso portfólio e tem interesse nele?\n\n<:pix:1150473428537720863> | Abra um ticket e tire suas dúvidas!\n\n<:Lua:1149783576267735193> | Não abra um ticket sem finalidade alguma, atenção às nossas regras!**') .setColor('#3498db') .setImage('https://media.discordapp.net/attachments/1137418719254024273/1149801294576500796/image.png?width=1440&height=243'); const selectMenu = new MessageSelectMenu() .setCustomId('ticket_category') .setPlaceholder('Selecione uma categoria') .addOptions([ { label: 'ROUPA', value: 'roupa', }, { label: 'CARROS', value: 'carros', }, { label: 'ARMAS', value: 'armas', }, { label: 'BOT-DC', value: 'bot-dc', }, ]); const row = new MessageActionRow().addComponents(selectMenu); const sentMessage = await message.channel.send({ embeds: [embed], components: [row] }); } }); client.on('interactionCreate', async (interaction) => { if (interaction.isSelectMenu()) { console.log(`Menu suspenso selecionado: ${interaction.customId}`); const categoryValue = interaction.values[0]; let category_name; switch (categoryValue) { case 'roupa': category_name = 'ROUPA'; break; case 'carros': category_name = 'CARROS'; break; case 'armas': category_name = 'ARMAS'; break; case 'bot-dc': category_name = 'BOT-DC'; break; default: return; } const guild = interaction.guild; const category = guild.channels.cache.find( (c) => c.name === category_name && c.type === 'GUILD_CATEGORY' ); if (!category) { const newCategory = await guild.channels.create(category_name, { type: 'GUILD_CATEGORY', }); const ticketChannel = await guild.channels.create(`ticket-${category_name}`, { type: 'GUILD_TEXT', parent: newCategory.id, }); const ticketEmbed = new MessageEmbed() .setTitle(`Ticket de ${category_name}`) .setDescription( `Olá, ${interaction.user.toString()}! Bem-vindo ao seu ticket de ${category_name}. Por favor, descreva o seu problema ou pergunta aqui.` ) .setColor('#2ecc71'); if (ticketChannel) { const buttons = new MessageActionRow() .addComponents( new MessageButton() .setCustomId('close_ticket') .setLabel('Sair') .setStyle('PRIMARY'), new MessageButton() .setCustomId('staff_actions') .setLabel('Ações da Staff') .setStyle('SECONDARY') ); await ticketChannel.send({ embeds: [ticketEmbed], components: [buttons] }); } } await interaction.reply(`Canal de ticket da categoria ${category_name} criado com sucesso!`); } else if (interaction.isButton()) { console.log(`Botão clicado: ${interaction.customId}`); if (interaction.customId === 'close_ticket') { // Adicione o código para fechar o ticket aqui return; } else if (interaction.customId === 'staff_actions') { const options = new MessageActionRow() .addComponents( new MessageSelectMenu() .setCustomId('staff_action_select') .setPlaceholder('Selecione uma ação') .addOptions([ { label: 'Timeout', value: 'timeout', }, { label: 'Finalizar Ticket', value: 'close_ticket', }, { label: 'Poke', value: 'poke', }, ]) ); await interaction.update({ components: [options] }); } } }); client.on('interactionCreate', async (interaction) => { if (interaction.isSelectMenu() && interaction.customId === 'staff_action_select') { console.log(`Menu suspenso de ações da staff selecionado: ${interaction.values[0]}`); const selectedAction = interaction.values[0]; if (selectedAction === 'timeout') { // Adicione o código para aplicar um timeout ao usuário } else if (selectedAction === 'close_ticket') { // Adicione o código para finalizar o ticket } else if (selectedAction === 'poke') { // Adicione o código para enviar uma mensagem de "poke" } } }); client.login(token);