skip to content
Fulldroper`s personal site

Discord Bot Tickets

/ 2 min read

Last Updated:

The purpose of the project was to create a Discord bot that adds the ability to create tickets for review and threads for ease of use and moderation.

The project is useful as it helps server administrators and moderators manage user requests and issues more efficiently by organizing them into tickets and threads.

How the project works

The bot connects to a Discord server and listens for commands to create tickets. When a user creates a ticket, the bot generates a thread where the issue can be discussed and resolved.

You can find the repository and installation instructions at the following link: Discord Bot Tickets

Algorithm and Code Examples

  1. Connecting to Discord Server
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('YOUR_BOT_TOKEN');
client.on('ready', () => {
console.log('Logged in as ' + client.user.tag + '!');
});
  1. Creating Tickets
client.on('message', message => {
if (message.content.startsWith('!ticket')) {
const ticketChannel = message.guild.channels.cache.find(ch => ch.name === 'tickets');
if (ticketChannel) {
ticketChannel.send('A new ticket has been created by ' + message.author.tag);
} else {
message.guild.channels.create('tickets', { type: 'text' }).then(channel => {
channel.send('A new ticket has been created by ' + message.author.tag);
});
}
}
});
  1. Creating Threads for Tickets
client.on('message', message => {
if (message.content.startsWith('!ticket')) {
const ticketChannel = message.guild.channels.cache.find(ch => ch.name === 'tickets');
if (ticketChannel) {
ticketChannel.threads.create({
name: 'ticket-' + message.author.tag,
autoArchiveDuration: 60,
reason: 'Ticket thread'
}).then(threadChannel => {
threadChannel.send('Please describe your issue, ' + message.author.tag);
});
}
}
});

Skills Acquired

  • Advanced JavaScript and Node.js programming
  • Working with the Discord API
  • Managing channels and threads in Discord
  • Implementing ticketing systems for better moderation