diff --git a/commands/admin/autoresponse.js b/commands/admin/autoresponse.js index 13784356..664d5818 100644 --- a/commands/admin/autoresponse.js +++ b/commands/admin/autoresponse.js @@ -9,13 +9,14 @@ export default { category: 'admin', async execute(interaction, args, client) { const autoresponseStat = await db.autoresponseStat.findOne({ where: { serverID: interaction.guild.id } }); - - if (autoresponseStat.stat !== 'enable') { + console.log(autoresponseStat); + if (!autoresponseStat) { const body = { serverID: interaction.guild.id, stat: 'enable' }; await db.autoresponseStat.create(body); return await interaction.reply({ content: 'Autoresponse has been enabled.', ephemeral: true }); } + const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() @@ -30,7 +31,14 @@ export default { .setStyle(ButtonStyle.Danger), ); - await interaction.reply({ content: 'Autoresponse is already enabled, do you wish to disable it?', components: [row], ephemeral: true }); + if (autoresponseStat.stat === 'enable') { + await interaction.reply({ content: 'Autoresponse is already enabled, do you wish to disable it?', components: [row], ephemeral: true }); + } + else { + const body = { serverID: interaction.guild.id, stat: 'enable' }; + await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } }); + return interaction.editReply({ content: 'Auto response has been enabled.', ephemeral: true }); + } client.on('interactionCreate', async (interactionMenu) => { if (interaction.user !== interactionMenu.user) return; @@ -46,4 +54,4 @@ export default { } }); }, -}; +}; \ No newline at end of file diff --git a/commands/admin/quotation.js b/commands/admin/quotation.js index f768a5ea..ef388e24 100644 --- a/commands/admin/quotation.js +++ b/commands/admin/quotation.js @@ -10,12 +10,13 @@ export default { async execute(interaction, args, client) { const quotationstat = await db.quotationStat.findOne({ where: { serverID: interaction.guild.id } }); - if (quotationstat.stat !== 'enable') { + if (!quotationstat) { const body = { serverID: interaction.guild.id, stat: 'enable' }; await db.quotationStat.create(body); return await interaction.reply({ content: 'Quotation has been enabled.', ephemeral: true }); } + const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() @@ -30,7 +31,14 @@ export default { .setStyle(ButtonStyle.Danger), ); - await interaction.reply({ content: 'Quotation is already enabled, do you wish to disable it?', components: [row], ephemeral: true }); + if (quotationstat.stat === 'enable') { + await interaction.reply({ content: 'Quotation is already enabled, do you wish to disable it?', components: [row], ephemeral: true }); + } + else { + const body = { serverID: interaction.guild.id, stat: 'enable' }; + await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } }); + return interaction.editReply({ content: 'Quotation has been enabled.', ephemeral: true }); + } client.on('interactionCreate', async (interactionMenu) => { if (interaction.user !== interactionMenu.user) return;