Skip to content

اا #15

@hsjdjjsjsj

Description

@hsjdjjsjsj

// ticketBot.js

const { Client, GatewayIntentBits, Partials, ChannelType, PermissionsBitField, ButtonBuilder, ButtonStyle, ActionRowBuilder, Events } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers],
partials: [Partials.Channel]
});

client.once('ready', () => {
console.log(✅ Logged in as ${client.user.tag});
});

client.on(Events.InteractionCreate, async interaction => {
if (interaction.isChatInputCommand()) {
if (interaction.commandName === 'setup-ticket') {
const button = new ButtonBuilder()
.setCustomId('create_ticket')
.setLabel('فتح تذكرة')
.setStyle(ButtonStyle.Primary);

  const row = new ActionRowBuilder().addComponents(button);

  await interaction.reply({ content: 'اضغط الزر لفتح تذكرة:', components: [row] });
}

}

if (interaction.isButton()) {
if (interaction.customId === 'create_ticket') {
const existing = interaction.guild.channels.cache.find(c => c.name === ticket-${interaction.user.id});
if (existing) return interaction.reply({ content: 'لديك تذكرة مفتوحة مسبقًا!', ephemeral: true });

  const channel = await interaction.guild.channels.create({
    name: `ticket-${interaction.user.id}`,
    type: ChannelType.GuildText,
    permissionOverwrites: [
      {
        id: interaction.guild.roles.everyone,
        deny: [PermissionsBitField.Flags.ViewChannel]
      },
      {
        id: interaction.user.id,
        allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages]
      },
      {
        id: 'ROLE_ID_الدعم', // عدله برقم رول الدعم
        allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages]
      }
    ]
  });

  const closeButton = new ButtonBuilder()
    .setCustomId('close_ticket')
    .setLabel('إغلاق التذكرة')
    .setStyle(ButtonStyle.Danger);

  const row = new ActionRowBuilder().addComponents(closeButton);

  await channel.send({
    content: `مرحبًا <@${interaction.user.id}>! الرجاء كتابة مشكلتك هنا.`,
    components: [row]
  });

  await interaction.reply({ content: `✅ تم فتح تذكرتك: ${channel}`, ephemeral: true });
}

if (interaction.customId === 'close_ticket') {
  await interaction.channel.send('📌 سيتم إغلاق التذكرة بعد 5 ثوانٍ...');
  setTimeout(() => {
    interaction.channel.delete();
  }, 5000);
}

}
});

client.login('‏MTM1NzU5NjcwMjAwMDk0MzEwNQ.GOeSem.-mpzDqiiMzwA1BC5Slc02w8y-whkCnYpAXM66Q');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions