feat: feedback, start of close requests

This commit is contained in:
Isaac
2023-01-13 20:48:37 +00:00
parent d7e1b05586
commit 8bf01aa520
16 changed files with 293 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
const { Button } = require('@eartharoid/dbf');
const { isStaff } = require('../lib/users');
module.exports = class CloseButton extends Button {
constructor(client, options) {
@@ -16,6 +17,29 @@ module.exports = class CloseButton extends Button {
/** @type {import("client")} */
const client = this.client;
await interaction.deferReply();
if (id.accepted === undefined) {
await client.tickets.beforeRequestClose(interaction);
} else {
// {
// action: 'close',
// expect: staff ? 'user' : 'staff',
// reason: interaction.options?.getString('reason', false) || null, // ?. because it could be a button interaction
// requestedBy: interaction.user.id,
// }
await interaction.deferReply();
const ticket = await client.prisma.ticket.findUnique({
include: { guild: true },
where: { id: interaction.channel.id },
});
if (id.expect === 'staff' && !await isStaff(interaction.guild, interaction.user.id)) {
return;
} else if (interaction.user.id !== ticket.createdById) {
return;
// if user and expect user (or is creator), feedback modal (if enabled)
// otherwise add "Give feedback" button in DM message (if enabled)
}
}
}
};

View File

@@ -2,8 +2,8 @@ const { Button } = require('@eartharoid/dbf');
const {
ActionRowBuilder,
ModalBuilder,
SelectMenuBuilder,
SelectMenuOptionBuilder,
StringSelectMenuBuilder,
StringSelectMenuOptionBuilder,
TextInputBuilder,
TextInputStyle,
} = require('discord.js');
@@ -86,14 +86,14 @@ module.exports = class EditButton extends Button {
} else if (a.question.type === 'MENU') {
return new ActionRowBuilder()
.setComponents(
new SelectMenuBuilder()
new StringSelectMenuBuilder()
.setCustomId(a.question.id)
.setPlaceholder(a.question.placeholder || a.question.label)
.setMaxValues(a.question.maxLength)
.setMinValues(a.question.minLength)
.setOptions(
a.question.options.map((o, i) => {
const builder = new SelectMenuOptionBuilder()
const builder = new StringSelectMenuOptionBuilder()
.setValue(String(i))
.setLabel(o.label);
if (o.description) builder.setDescription(o.description);