Discord_API_Bot/slash-commands/remove-question.js

41 lines
No EOL
1.2 KiB
JavaScript

const { ticket_settings } = require('../config');
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("remove-question")
.setDescription("Remove the question from ticket form")
.addStringOption(option =>
option
.setRequired(true)
.setName("question")
.setAutocomplete(true)
.setDescription("Select the question.")
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async run(interaction) {
let { options } = interaction;
const deferOptions = { ephemeral: true };
await interaction.deferReply(deferOptions);
let questionId = options.getString("question");
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 question from ticket form!");
db.query(`DELETE FROM questions WHERE id='${questionId}'`);
const replyOptions = {
embeds: [removeEmbed],
ephemeral: true
};
return interaction.editReply(replyOptions);
}
};