Build a ticket system: /ticket panel posts a card with one line per ticket type (support, report, application), each with its description and its own button; pressing one opens a form with two questions specific to that type, then a private thread named after the type, a number and the member, with the answers on a card, the member and the @Staff role; /ticket add brings another member in, /ticket close asks the member to rate the help from 1 to 5 with buttons, posts the rating in a channel I choose and archives the thread; an hourly check archives any ticket silent for 48 hours
A full-featured ticket system for support, reports and applications.
How it works:
/ticket panel posts a card with one line per ticket type โ Support, Report and Application โ each with its own button/ticket add @member brings someone into the ticket/ticket close asks the ticket author to rate the help from 1-5 stars, posts the rating to your chosen channel, then archives the threadSetup: Set the staff role (pinged in new tickets) and the ratings channel (where ratings are posted) in the settings.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
Pick what your ticket is about: a short form opens, then a private thread with the staff.
๐ฌ Support Get help with the server or a problem
๐จ Report Report a member or an issue
๐ Application Apply to join the team
Only you and the staff see your ticket. Tickets silent for 48 hours close by themselves.
// Ticket system with panels, forms, private threads, ratings and auto-close
mee6.settings({
staff_role: { type: 'role', label: 'Staff role (pinged in new tickets)', required: true, sample: 'Staff' },
ratings_channel: { type: 'channel', label: 'Where to post ratings', required: true, sample: 'ticket-ratings' },
});
interface OpenTicket {
threadId: string;
lastActivity: number;
}
// Every open ticket in one list: the hourly sweep reads one value instead of
// walking every key, and a message in a ticket updates one entry.
const OPEN_KEY = 'open_tickets';
// The colour bar of each ticket type's card
const COLORS: Record<string, number> = { support: 0x5865f2, report: 0xed4245, application: 0x57f287 };
/** A Discord timestamp: each member reads it in their own time zone */
function timestamp(): string {
return `<t:${Math.floor(Date.now() / 1000)}:f>`;
}
async function openTickets(): Promise<OpenTicket[]> {
return (await mee6.store.get<OpenTicket[]>(OPEN_KEY)) || [];
}
async function forgetTicket(threadId: string): Promise<void> {
const open = await openTickets();
await mee6.store.set(
OPEN_KEY,
open.filter((t) => t.threadId !== threadId)
);
await mee6.store.delete(`ticket_${threadId}`);
}
// Three ticket types, each with its own form
mee6.modal('support_form', {
title: 'Support Ticket',
fields: [
{ name: 'issue', label: 'What do you need help with?', style: 'paragraph', maxLength: 500 },
{ name: 'attempted', label: 'What have you tried so far?', style: 'paragraph', maxLength: 300 },
],
});
// A report names the member involved with Discord's own picker, and may
// carry screenshots: they are posted in the ticket, where they stay
mee6.modal('report_form', {
title: 'Report',
fields: [
{
name: 'member',
type: 'user',
label: 'Member involved',
description: 'Leave it empty to report an issue rather than a member',
required: false,
},
{ name: 'details', label: 'What happened?', style: 'paragraph', maxLength: 500 },
{
name: 'proof',
type: 'file',
label: 'Screenshots',
description: 'Up to 3 pictures',
fileTypes: ['image'],
maxValues: 3,
required: false,
},
],
});
mee6.modal('application_form', {
title: 'Application',
fields: [
{ name: 'why', label: 'Why do you want to join the team?', style: 'paragraph', maxLength: 500 },
{ name: 'experience', label: 'Relevant experience?', style: 'paragraph', maxLength: 300 },
],
});
// Admin command: post the ticket panel
mee6.command('ticket panel', { description: 'Post the ticket panel (admins only)' }, async (ctx) => {
// One card, one line per ticket type with the button that opens its form
await ctx.reply({
layout: [
{
type: 'container',
color: COLORS.support,
blocks: [
{
type: 'text',
text: '## ๐ซ Support Tickets\nPick what your ticket is about: a short form opens, then a private thread with the staff.',
},
{ type: 'separator' },
{
type: 'section',
text: '**๐ฌ Support**\nGet help with the server or a problem',
button: { label: 'Get help', opens: 'support_form', style: 'primary' },
},
{
type: 'section',
text: '**๐จ Report**\nReport a member or an issue',
button: { label: 'Report', opens: 'report_form', style: 'danger' },
},
{
type: 'section',
text: '**๐ Application**\nApply to join the team',
button: { label: 'Apply', opens: 'application_form', style: 'success' },
},
{ type: 'separator' },
{
type: 'text',
text: '-# Only you and the staff see your ticket. Tickets silent for 48 hours close by themselves.',
},
],
},
],
});
});
// When a form is submitted, create the thread
mee6.on('modal', async (ctx) => {
const staffRoleId = ctx.settings.staff_role;
if (!staffRoleId) {
await ctx.reply({
content: 'Tickets are not configured yet โ an admin needs to set the staff role.',
ephemeral: true,
});
return;
}
let type = '';
let emoji = '';
// What the member answered, one labelled line each on the ticket's card
let answers: [string, string][] = [];
// Pictures sent with the form, posted with the card
let files: FormFile[] = [];
if (ctx.customId === 'support_form') {
type = 'support';
emoji = '๐ฌ';
answers = [
['Issue', ctx.fields.issue as string],
['Attempted', ctx.fields.attempted as string],
];
} else if (ctx.customId === 'report_form') {
type = 'report';
emoji = '๐จ';
const member = (ctx.fields.member as string[] | undefined)?.[0];
answers = [
['Member involved', member ? `<@${member}>` : ''],
['Details', ctx.fields.details as string],
];
files = (ctx.fields.proof as FormFile[] | undefined) ?? [];
} else if (ctx.customId === 'application_form') {
type = 'application';
emoji = '๐';
answers = [
['Why', ctx.fields.why as string],
['Experience', ctx.fields.experience as string],
];
} else {
return;
}
// Increment ticket counter
const num = await mee6.store.incr(`ticket_${type}_count`);
const threadName = `${emoji} ${type}-${num} ${ctx.author.username}`;
// Create the private thread in the current channel
const thread = await mee6.createThread(ctx.channelId, threadName, { private: true });
// Post the ticket details in the thread: the mentions bring the member and
// the staff in, the card below holds the answers
await ctx.send(thread.threadId, {
content: `<@${ctx.author.id}> <@&${staffRoleId}>`,
layout: [
{
type: 'container',
color: COLORS[type],
blocks: [
{ type: 'text', text: `## ${emoji} ${type.charAt(0).toUpperCase() + type.slice(1)} Ticket #${num}` },
{ type: 'separator' },
...answers.map(([label, value]): LayoutBlock => ({ type: 'text', text: `**${label}**\n${value || 'โ'}` })),
{ type: 'separator' },
{ type: 'text', text: `-# Opened by ${ctx.author.username} ยท ${timestamp()}` },
],
},
],
// The screenshots, shown under the card as a gallery
files,
});
// Store ticket metadata, and list it among the open tickets
await mee6.store.set(
`ticket_${thread.threadId}`,
{
type,
number: num,
authorId: ctx.author.id,
openedAt: Date.now(),
},
{ ttl: 31536000 }
); // 1 year
const open = await openTickets();
open.push({ threadId: thread.threadId, lastActivity: Date.now() });
await mee6.store.set(OPEN_KEY, open);
await ctx.reply({ content: `โ
Your ${type} ticket has been created: <#${thread.threadId}>`, ephemeral: true });
});
// Track activity in ticket threads
mee6.on('message', async (ctx) => {
const open = await openTickets();
const ticket = open.find((t) => t.threadId === ctx.channelId);
if (ticket) {
ticket.lastActivity = Date.now();
await mee6.store.set(OPEN_KEY, open);
}
});
// Add someone to a ticket
mee6.command(
'ticket add',
{
description: 'Add a member to this ticket',
options: [{ name: 'member', type: 'user', description: 'Who to add', required: true }],
},
async (ctx) => {
const ticket = await mee6.store.get<any>(`ticket_${ctx.channelId}`);
if (!ticket) {
await ctx.reply({ content: 'This is not a ticket thread.', ephemeral: true });
return;
}
// Mentioning someone in a private thread is how Discord adds them to it:
// the mention below is the invitation.
const memberId = ctx.option<string>('member');
await ctx.reply(`<@${memberId}> has been added to this ticket.`);
}
);
// Close a ticket with a rating
mee6.command('ticket close', { description: 'Close this ticket' }, async (ctx) => {
const ticket = await mee6.store.get<any>(`ticket_${ctx.channelId}`);
if (!ticket) {
await ctx.reply({ content: 'This is not a ticket thread.', ephemeral: true });
return;
}
const channel = await mee6.getChannel(ctx.channelId);
if (!channel || channel.type !== 'thread') {
await ctx.reply({ content: 'This command only works in ticket threads.', ephemeral: true });
return;
}
// Ask for a rating
await ctx.reply({
content: `<@${ticket.authorId}>`,
layout: [
{
type: 'container',
color: COLORS[ticket.type] ?? COLORS.support,
blocks: [
{ type: 'text', text: '### How would you rate the help you received?' },
{
type: 'buttons',
buttons: [
{ label: '1', customId: 'rate_1', style: 'danger' },
{ label: '2', customId: 'rate_2', style: 'danger' },
{ label: '3', customId: 'rate_3', style: 'secondary' },
{ label: '4', customId: 'rate_4', style: 'success' },
{ label: '5', customId: 'rate_5', style: 'success' },
],
},
{ type: 'text', text: '-# 1 is poor, 5 is excellent. The ticket closes once you rate it.' },
],
},
],
});
});
// Handle rating buttons
mee6.on('button', async (ctx) => {
if (!ctx.customId.startsWith('rate_')) return;
const ticket = await mee6.store.get<any>(`ticket_${ctx.channelId}`);
if (!ticket) return;
// Only the ticket author can rate
if (ctx.author.id !== ticket.authorId) {
await ctx.reply({ content: 'Only the ticket author can rate.', ephemeral: true });
return;
}
const rating = parseInt(ctx.customId.split('_')[1], 10);
const stars = 'โญ'.repeat(rating);
// Post rating to the ratings channel
const ratingsChannel = ctx.settings.ratings_channel;
if (ratingsChannel) {
await ctx.send(ratingsChannel, {
layout: [
{
type: 'container',
color: rating >= 4 ? 0x57f287 : rating === 3 ? 0xfee75c : 0xed4245,
blocks: [
{ type: 'text', text: '## ๐ Ticket Closed' },
{ type: 'text', text: `**Ticket:** ${ticket.type} #${ticket.number}\n**Rating:** ${stars} (${rating}/5)` },
{ type: 'text', text: `-# By ${ctx.author.username} ยท ${timestamp()}` },
],
},
],
});
}
await ctx.reply(`Thank you for your feedback! ${stars}`);
// Archive the thread and forget the ticket
await mee6.archiveThread(ctx.channelId);
await forgetTicket(ctx.channelId);
});
// Hourly check: archive tickets silent for 48+ hours
mee6.schedule.every('auto_close_tickets', 3600, {});
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey !== 'auto_close_tickets') return;
const now = Date.now();
const threshold = 48 * 60 * 60 * 1000; // 48 hours in ms
const open = await openTickets();
const stale = open.filter((t) => now - t.lastActivity > threshold).slice(0, 10);
if (stale.length === 0) return;
for (const t of stale) {
try {
await mee6.archiveThread(t.threadId);
mee6.log(`Auto-closed ticket ${t.threadId} after 48h without a message`);
} catch (e) {
mee6.log(`Could not archive ${t.threadId}: ${e}`); // already archived, or gone
}
await mee6.store.delete(`ticket_${t.threadId}`);
}
const closed = new Set(stale.map((t) => t.threadId));
await mee6.store.set(
OPEN_KEY,
open.filter((t) => !closed.has(t.threadId))
);
});