9

Develop an advanced Discord ticket bot named "Ticket Bot" that utilizes Discord.js v14 allowing it to operate seamlessly across an unlimited number of Discord servers. The bot should feature a command system for creating, viewing, and closing tickets using interactive embeds, and implement role-based permissions to manage ticket access. Additionally, integrate a logging system to capture ticket activities, and ensure that the bot can handle multiple languages for global accessibility.

Kodari AI
KodariMar 2 at 12:57 pm 19,759 (v2)

I’ll create an advanced Discord.js v14 ticket bot with multi-server support, role-based permissions, logging, and multi-language capabilities.

AdvancedTicketBot
A sophisticated Discord ticket management system built with Discord.js v14. Features include slash commands for ticket creation and management, interactive embeds, role-based access control, comprehensive activity logging, and multi-language support for global accessibility. Designed to operate seamlessly across unlimited Discord servers with persistent ticket data, automated transcripts, and customizable configurations per guild.

Perfect! I’ve created a comprehensive Discord.js v14 ticket bot with the following features:

Core Features:

  • ✅ Multi-server support with per-guild configurations

  • ✅ Slash commands (/ticket, /ticketsetup, /ticketconfig, /closeticket, /ticketinfo)

  • ✅ Interactive embeds with button components (Claim, Close, Delete)

  • ✅ Role-based permission system

  • ✅ Comprehensive logging system for all ticket activities

  • ✅ Multi-language support (English, Spanish, French, German)

Technical Highlights:

  • Persistent JSON database for tickets, guilds, and users

  • Automatic ticket transcripts sent to configured channels

  • Maximum tickets per user limit (configurable)

  • Support role management for ticket access

  • Auto-categorization system

  • User notifications via DM when tickets are closed

  • Message tracking for transcripts

Setup Instructions:

  1. Run npm install to install dependencies

  2. Add your bot token and client ID to .env

  3. Run npm start to launch the bot

  4. Use /ticketsetup in your server to configure categories, channels, and roles

  5. Users can create tickets with /ticket

Kodari can make mistakes. Review important code before using.
Files
src
.gitignore
config.json
index.js
package.json
README.md
Code
25 1,554
index.js
const { Client, GatewayIntentBits, Collection, REST, Routes } = require('discord.js');
const { readdirSync } = require('fs');
const { join } = require('path');
require('dotenv').config();

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers
  ]
});

client.commands = new Collection();
client.buttons = new Collection();

const Database = require('./src/database/Database');
const Logger = require('./src/utils/Logger');
const LanguageManager = require('./src/utils/LanguageManager');
const TicketManager = require('./src/utils/TicketManager');

client.db = new Database();
client.logger = new Logger();
client.lang = new LanguageManager();
client.tickets = new TicketManager(client);

const loadCommands = () => {
  const commandFiles = readdirSync(join(__dirname, 'src', 'commands')).filter(file => file.endsWith('.js'));
  
  for (const file of commandFiles) {
    const command = require(join(__dirname, 'src', 'commands', file));
    client.commands.set(command.data.name, command);
    client.logger.info(`Loaded command: ${command.data.name}`);
  }
};

const loadEvents = () => {
  const eventFiles = readdirSync(join(__dirname, 'src', 'events')).filter(file => file.endsWith('.js'));
  
  for (const file of eventFiles) {
    const event = require(join(__dirname, 'src', 'events', file));
    if (event.once) {
      client.once(event.name, (...args) => event.execute(...args, client));
    } else {
      client.on(event.name, (...args) => event.execute(...args, client));
    }
    client.logger.info(`Loaded event: ${event.name}`);
  }
};

const loadButtons = () => {
  const buttonFiles = readdirSync(join(__dirname, 'src', 'buttons')).filter(file => file.endsWith('.js'));
  
  for (const file of buttonFiles) {
    const button = require(join(__dirname, 'src', 'buttons', file));
    client.buttons.set(button.customId, button);
    client.logger.info(`Loaded button: ${button.customId}`);
  }
};

const deployCommands = async () => {
  const commands = [];
  client.commands.forEach(command => {
    commands.push(command.data.toJSON());
  });

  const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);

  try {
    client.logger.info('Started refreshing application (/) commands.');

    await rest.put(
      Routes.applicationCommands(process.env.CLIENT_ID),
      { body: commands }
    );

    client.logger.success('Successfully reloaded application (/) commands.');
  } catch (error) {
    client.logger.error('Error deploying commands:', error);
  }
};

loadCommands();
loadEvents();
loadButtons();

client.login(process.env.DISCORD_TOKEN).then(() => {
  deployCommands();
});

process.on('unhandledRejection', error => {
  client.logger.error('Unhandled promise rejection:', error);
});