2022-08-29 21:06:27 +02:00
|
|
|
import { SlashCommandBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder, PermissionFlagsBits } from 'discord.js';
|
|
|
|
import db from '../../models/index.js';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
.setName('quotation')
|
2022-08-30 22:58:23 +02:00
|
|
|
.setDescription('Enable or disable quotations')
|
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
2022-08-30 04:06:15 +02:00
|
|
|
category: 'admin',
|
2022-08-29 21:06:27 +02:00
|
|
|
async execute(interaction, args, client) {
|
|
|
|
const quotationstat = await db.quotationstat.findOne({ where: { serverID: interaction.guild.id } });
|
|
|
|
|
|
|
|
if (quotationstat.stat !== 'enable') {
|
|
|
|
const body = { serverID: interaction.guild.id, stat: 'enable' };
|
|
|
|
await db.quotationstat.create(body);
|
2022-08-30 04:06:15 +02:00
|
|
|
return await interaction.reply({ content: 'Quotation has been enabled.', ephemeral: true });
|
2022-08-29 21:06:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const row = new ActionRowBuilder()
|
|
|
|
.addComponents(
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setCustomId('yes')
|
|
|
|
.setLabel('Yes')
|
|
|
|
.setStyle(ButtonStyle.Primary),
|
|
|
|
)
|
|
|
|
.addComponents(
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setCustomId('no')
|
|
|
|
.setLabel('No')
|
|
|
|
.setStyle(ButtonStyle.Danger),
|
|
|
|
);
|
|
|
|
|
2022-08-30 04:06:15 +02:00
|
|
|
await interaction.reply({ content: 'Quotation is already enabled, do you wish to disable it?', components: [row], ephemeral: true });
|
2022-08-29 21:06:27 +02:00
|
|
|
|
|
|
|
client.once('interactionCreate', async (interactionMenu) => {
|
|
|
|
if (!interactionMenu.isButton) return;
|
|
|
|
interactionMenu.update({ components: [] });
|
|
|
|
if (interactionMenu.customId === 'yes') {
|
|
|
|
const body = { serverID: interaction.guild.id, stat: 'disable' };
|
|
|
|
await db.quotationstat.update(body, { where: { serverID: interaction.guild.id } });
|
2022-08-30 04:06:15 +02:00
|
|
|
return interaction.editReply({ content: 'Quotation has been disabled.', ephemeral: true });
|
2022-08-29 21:06:27 +02:00
|
|
|
}
|
|
|
|
else {
|
2022-08-30 04:06:15 +02:00
|
|
|
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
2022-08-29 21:06:27 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|