mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 12:23:09 +02:00
feat: add /topic
command
This commit is contained in:
parent
30883032b7
commit
f27feea2f9
@ -1,5 +1,12 @@
|
|||||||
const { SlashCommand } = require('@eartharoid/dbf');
|
const { SlashCommand } = require('@eartharoid/dbf');
|
||||||
const { ApplicationCommandOptionType } = require('discord.js');
|
const {
|
||||||
|
ActionRowBuilder,
|
||||||
|
ModalBuilder,
|
||||||
|
TextInputBuilder,
|
||||||
|
TextInputStyle,
|
||||||
|
} = require('discord.js');
|
||||||
|
const Cryptr = require('cryptr');
|
||||||
|
const { decrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||||
|
|
||||||
module.exports = class TopicSlashCommand extends SlashCommand {
|
module.exports = class TopicSlashCommand extends SlashCommand {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -19,5 +26,46 @@ module.exports = class TopicSlashCommand extends SlashCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(interaction) { }
|
/**
|
||||||
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
|
*/
|
||||||
|
async run(interaction) {
|
||||||
|
/** @type {import("client")} */
|
||||||
|
const client = this.client;
|
||||||
|
|
||||||
|
const ticket = await client.prisma.ticket.findUnique({
|
||||||
|
select: {
|
||||||
|
category: { select: { name: true } },
|
||||||
|
guild: { select: { locale: true } },
|
||||||
|
questionAnswers: { include: { question: true } },
|
||||||
|
topic: true,
|
||||||
|
},
|
||||||
|
where: { id: interaction.channel.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
||||||
|
|
||||||
|
await interaction.showModal(
|
||||||
|
new ModalBuilder()
|
||||||
|
.setCustomId(JSON.stringify({
|
||||||
|
action: 'topic',
|
||||||
|
edit: true,
|
||||||
|
}))
|
||||||
|
.setTitle(ticket.category.name)
|
||||||
|
.setComponents(
|
||||||
|
new ActionRowBuilder()
|
||||||
|
.setComponents(
|
||||||
|
new TextInputBuilder()
|
||||||
|
.setCustomId('topic')
|
||||||
|
.setLabel(getMessage('modals.topic.label'))
|
||||||
|
.setStyle(TextInputStyle.Paragraph)
|
||||||
|
.setMaxLength(1000)
|
||||||
|
.setMinLength(5)
|
||||||
|
.setPlaceholder(getMessage('modals.topic.placeholder'))
|
||||||
|
.setRequired(true)
|
||||||
|
.setValue(ticket.topic ? decrypt(ticket.topic) : ''),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user