mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-04 09:21:25 +03:00
feat: feedback, start of close requests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user