Use SQL sort

This commit is contained in:
Isaac 2022-08-09 22:47:24 +01:00
parent 1992072493
commit 0bc02e808a
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A

View File

@ -40,7 +40,7 @@ module.exports = class TicketManager {
category = await this.client.prisma.category.findUnique({ category = await this.client.prisma.category.findUnique({
include: { include: {
guild: true, guild: true,
questions: true, questions: { orderBy: { order: 'asc' } },
}, },
where: { id: Number(categoryId) }, where: { id: Number(categoryId) },
}); });
@ -192,7 +192,6 @@ module.exports = class TicketManager {
.setComponents( .setComponents(
category.questions category.questions
.filter(q => q.type === 'TEXT') // TODO: remove this when modals support select menus .filter(q => q.type === 'TEXT') // TODO: remove this when modals support select menus
.sort((a, b) => a.order - b.order)
.map(q => { .map(q => {
if (q.type === 'TEXT') { if (q.type === 'TEXT') {
return new ActionRowBuilder() return new ActionRowBuilder()
@ -351,7 +350,6 @@ module.exports = class TicketManager {
.setColor(category.guild.primaryColour) .setColor(category.guild.primaryColour)
.setFields( .setFields(
category.questions category.questions
.sort((a, b) => a.order - b.order)
.map(q => ({ .map(q => ({
name: q.label, name: q.label,
value: interaction.fields.getTextInputValue(q.id) || getMessage('ticket.answers.no_value'), value: interaction.fields.getTextInputValue(q.id) || getMessage('ticket.answers.no_value'),