Untitled
unknown
plain_text
a year ago
3.0 kB
14
Indexable
const { Client, GatewayIntentBits, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle,ChannelType, PermissionsBitField } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers] }); // Configuration const ticketPanelChannelId = '1225124137215852634'; // Replace with actual channel ID client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); client.user.setStatus('dnd'); // Send the ticket panel message (Run this on startup as needed) sendTicketPanel(); }); client.on('interactionCreate', async interaction => { if (!interaction.isButton()) return; if (interaction.customId === 'createTicket') { const guild = interaction.guild; const ticketCreator = interaction.user; // Generate a channel name (customize as needed) const ticketName = `ticket-${ticketCreator.id}`; try { console.log('ticketName:', ticketName); const channel = await guild.channels.create(ticketName, { name: ticketName, type: ChannelType.GuildText, permissionOverwrites: [ { id: ticketCreator.id, allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] }, { id: guild.id, // 'everyone' role deny: ['VIEW_CHANNEL'] }, // ... add roles with support permissions here ... ] }); // Welcome message await channel.send(`<@${ticketCreator.id}>, Welcome to your ticket! Please describe your issue, and a support member will be with you shortly.`); // Reply to the user await interaction.reply({ content: `Ticket created: ${channel}`, ephemeral: true }); } catch (error) { console.error('Error creating ticket channel:', error); interaction.reply({ content: 'There was an error creating your ticket. Please try again, or contact a staff member.', ephemeral: true }); } } }); function sendTicketPanel() { const ticketChannel = client.channels.cache.get(ticketPanelChannelId); const embed = new EmbedBuilder() .setTitle('Create a Ticket') .setDescription('Need help? Click the button below to open a new support ticket!'); const button = new ActionRowBuilder() .addComponents( new ButtonBuilder() .setCustomId('createTicket') .setLabel('Create Ticket') .setStyle(ButtonStyle.Primary) ); ticketChannel.send({ embeds: [embed], components: [button] }); } client.login('0MTkyMA.G_6xOV.O-lElqoZurHdMoK0wDOvNCW-uvkA5iUyX5Emio');
Editor is loading...
Leave a Comment