Build a support panel: a /panel command posts a card listing the kinds of request I configure (general help, report a problem…), each with its own Open Ticket button that opens a private thread with the member and the @Staff role, and a /close command that archives it
A support panel that opens private threads for members to get help from staff.
Setup:
/panel to post the panelUsage:
/close inside a thread to archive it (available to the opener and staff)Made by MEE6. Remix it to get a copy of your own and change anything you like.
Need help? Pick what it is about: a private thread opens with the staff.
💬 General help Questions about the server, its roles or its channels
🚨 Report a problem A member breaking the rules, a bug, something that broke
Only you and the staff see your thread. Close it with /close once you are done.
Support panel posted!
// Support panel: one card with a button per kind of request, each opening a private thread with staff
const BLURPLE = 0x5865f2;
mee6.settings({
staff_role: {
type: 'role',
label: 'Staff role to add to support threads',
required: true,
sample: 'Staff',
},
panel_channel: {
type: 'channel',
label: 'Channel where the panel should be posted',
required: true,
sample: 'support',
},
categories: {
type: 'list',
label: 'Kinds of request on the panel',
description: 'One line with its own button each. Leave empty for a single "Open Ticket" button.',
required: false,
maxItems: 10,
fields: {
name: { type: 'string', label: 'Name', required: true },
description: { type: 'string', label: 'What it is for', required: false },
},
default: [
{ name: '💬 General help', description: 'Questions about the server, its roles or its channels' },
{ name: '🚨 Report a problem', description: 'A member breaking the rules, a bug, something that broke' },
],
},
});
interface Category {
name: string;
description?: string;
}
function categories(settings: Record<string, StoredValue>): Category[] {
return ((settings.categories ?? []) as Category[]).filter((c) => c && c.name);
}
// Admin command: post the support panel
mee6.command('panel', { description: 'Post the support panel' }, async (ctx) => {
const channelId = ctx.settings.panel_channel;
if (!channelId) {
await ctx.reply('No panel channel is set — an admin can choose one in the dashboard.');
return;
}
// One line per kind of request, its button on the right. A panel without
// kinds keeps the single `open_ticket` button the first panels carried.
const kinds = categories(ctx.settings);
const rows: LayoutBlock[] = kinds.length
? kinds.map((kind, i) => ({
type: 'section',
text: kind.description ? `**${kind.name}**\n${kind.description}` : `**${kind.name}**`,
button: { label: 'Open Ticket', customId: `open_ticket:${i}`, style: 'primary' },
}))
: [
{
type: 'section',
text: '**Need help?**\nOpen a private thread with the staff.',
button: { label: 'Open Ticket', customId: 'open_ticket', style: 'primary' },
},
];
await ctx.send(channelId, {
layout: [
{
type: 'container',
color: BLURPLE,
blocks: [
{
type: 'text',
text: '## 🎫 Support\nNeed help? Pick what it is about: a private thread opens with the staff.',
},
{ type: 'separator' },
...rows,
{ type: 'separator' },
{
type: 'text',
text: '-# Only you and the staff see your thread. Close it with `/close` once you are done.',
},
],
},
],
});
await ctx.reply({ content: 'Support panel posted!', ephemeral: true });
});
// Handle button click: create private thread. `open_ticket` is the button of
// panels posted before the kinds of request; `open_ticket:<n>` the nth kind.
mee6.on('button', async (ctx) => {
if (ctx.customId !== 'open_ticket' && !ctx.customId.startsWith('open_ticket:')) return;
const staffRoleId = ctx.settings.staff_role;
if (!staffRoleId) {
await ctx.reply({ content: 'Staff role is not configured yet.', ephemeral: true });
return;
}
const index = ctx.customId.startsWith('open_ticket:') ? Number(ctx.customId.split(':')[1]) : -1;
const kind = categories(ctx.settings)[index];
// Create a private thread
const threadName = `${kind ? kind.name : 'Ticket'}: ${ctx.author.displayName}`.slice(0, 100);
const thread = await mee6.createThread(ctx.message.channelId, threadName, {
private: true,
autoArchiveMinutes: 1440,
});
// The mentions bring the member and the staff role into the thread
await ctx.send(thread.threadId, {
content: `<@${ctx.author.id}> <@&${staffRoleId}>`,
layout: [
{
type: 'container',
color: BLURPLE,
blocks: [
{ type: 'text', text: `## ${kind ? kind.name : '🎫 Support ticket'}` },
{ type: 'text', text: 'A staff member will be with you shortly. Tell us what you need in the meantime.' },
{ type: 'separator' },
{ type: 'text', text: '-# To close this ticket, use `/close`.' },
],
},
],
});
// Store who opened it so /close can validate
await mee6.store.set(`ticket_${thread.threadId}`, ctx.author.id, { ttl: 86400 * 7 });
await ctx.reply({ content: `Your ticket has been opened: <#${thread.threadId}>`, ephemeral: true });
});
// Close command: archive the thread (must be used inside the thread)
mee6.command('close', { description: 'Close the current support ticket', ephemeral: true }, async (ctx) => {
const channel = await mee6.getChannel(ctx.channelId);
if (!channel || channel.type !== 'thread') {
await ctx.reply('This command can only be used inside a support thread.');
return;
}
const staffRoleId = ctx.settings.staff_role;
const openedBy = await mee6.store.get<string>(`ticket_${ctx.channelId}`);
// Allow the member who opened it, or anyone with the staff role
const isStaff = staffRoleId && ctx.author.roles.includes(staffRoleId);
const isOpener = openedBy === ctx.author.id;
if (!isStaff && !isOpener) {
await ctx.reply('Only the member who opened this ticket or staff can close it.');
return;
}
await ctx.reply('Closing ticket...');
await mee6.archiveThread(ctx.channelId, { locked: true });
await mee6.store.delete(`ticket_${ctx.channelId}`);
});