55 lines
No EOL
1.6 KiB
JavaScript
55 lines
No EOL
1.6 KiB
JavaScript
const { ticket_settings } = require("../config");
|
|
const { queryMulti } = require("../helpers/helper");
|
|
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js");
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName("remove-ticket-option")
|
|
.setDescription("Remove the option from tickets")
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('option')
|
|
.setRequired(true)
|
|
.setAutocomplete(true)
|
|
.setDescription("Select the option.")
|
|
)
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
|
|
async run(interaction) {
|
|
let { options } = interaction;
|
|
|
|
const deferOptions = { ephemeral: true };
|
|
await interaction.deferReply(deferOptions);
|
|
|
|
let optionId = options.getString("option");
|
|
|
|
const authorText = { name: interaction.guild.name };
|
|
let removeEmbed = new EmbedBuilder()
|
|
.setColor(ticket_settings.embed_color)
|
|
.setAuthor(authorText)
|
|
.setThumbnail(ticket_settings.ticket_thumbnail)
|
|
.setDescription("You successfully removed the option!");
|
|
|
|
let existingOptions = await queryMulti(db, `SELECT * FROM options WHERE guildID='${interaction.guildId}'`);
|
|
|
|
const maxOptionsReply = {
|
|
embeds: [removeEmbed],
|
|
ephemeral: true
|
|
};
|
|
|
|
if (existingOptions.length > 5) {
|
|
return interaction.editReply(maxOptionsReply);
|
|
}
|
|
|
|
db.query(`DELETE FROM options WHERE id='${optionId}'`);
|
|
|
|
removeEmbed.setDescription("You successfully created new option!");
|
|
|
|
const successReply = {
|
|
embeds: [removeEmbed],
|
|
ephemeral: true
|
|
};
|
|
|
|
return interaction.editReply(successReply);
|
|
}
|
|
}; |