diff --git a/src/autocomplete/ticket.js b/src/autocomplete/ticket.js index 60b5e8b..ea4473b 100644 --- a/src/autocomplete/ticket.js +++ b/src/autocomplete/ticket.js @@ -1,4 +1,5 @@ const { Autocompleter } = require('@eartharoid/dbf'); +const emoji = require('node-emoji'); module.exports = class TicketCompleter extends Autocompleter { constructor(client, options) { @@ -18,6 +19,14 @@ module.exports = class TicketCompleter extends Autocompleter { const client = this.client; const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } }); const tickets = await client.prisma.ticket.findMany({ + include: { + category: { + select: { + emoji: true, + name: true, + }, + }, + }, where: { createdById: interaction.user.id, guildId: interaction.guild.id, @@ -34,8 +43,10 @@ module.exports = class TicketCompleter extends Autocompleter { .slice(0, 25) .map(t => { const date = new Date(t.createdAt).toLocaleString(settings.locale, { dateStyle: 'short' }); + const topic = t.topic ? '| ' + t.topic.substring(0, 50) : ''; + const category = emoji.hasEmoji(t.category.emoji) ? emoji.get(t.category.emoji) + ' ' + t.category.name : t.category.name; return { - name: `#${t.number} - ${date} ${t.topic ? '| ' + t.topic.substring(0, 50) : ''}`, + name: `${category} #${t.number} - ${date} ${topic}`, value: t.id, }; }), diff --git a/src/lib/tickets/manager.js b/src/lib/tickets/manager.js index 159ac08..cf215d7 100644 --- a/src/lib/tickets/manager.js +++ b/src/lib/tickets/manager.js @@ -192,31 +192,6 @@ module.exports = class TicketManager { }); } - // const lastTicket = await this.client.prisma.ticket.findFirst({ - // orderBy: [{ closedAt: 'desc' }], - // select: { closedAt: true }, - // where: { - // categoryId: category.id, - // createdById: interaction.user.id, - // open: false, - // }, - // }); - - // if (Date.now() - lastTicket.closedAt < category.cooldown) { - // return await interaction.reply({ - // embeds: [ - // new ExtendedEmbedBuilder({ - // iconURL: guild.iconURL(), - // text: category.guild.footer, - // }) - // .setColor(category.guild.errorColour) - // .setTitle(getMessage('misc.cooldown.title')) - // .setDescription(getMessage('misc.cooldown.description', { time: ms(category.cooldown - (Date.now() - lastTicket.closedAt)) })), - // ], - // ephemeral: true, - // }); - // } - const cooldown = await this.getCooldown(category.id, interaction.user.id); if (cooldown) { return await interaction.reply({ diff --git a/src/lib/tickets/utils.js b/src/lib/tickets/utils.js index 1fac854..9cae372 100644 --- a/src/lib/tickets/utils.js +++ b/src/lib/tickets/utils.js @@ -72,6 +72,5 @@ module.exports = { ephemeral: true, }); } - }, }; \ No newline at end of file