From 1a87dbb325a3d30fed7f0cd19514b960e3a186cf Mon Sep 17 00:00:00 2001 From: Supositware Date: Wed, 14 Sep 2022 11:31:19 +0200 Subject: [PATCH] Make the custom id unique --- commands/admin/autoresponse.js | 6 +++--- commands/admin/bye.js | 10 +++++----- commands/admin/quotation.js | 6 +++--- commands/admin/welcome.js | 10 +++++----- commands/owner/ublacklist.js | 6 +++--- commands/utility/download.js | 10 +++++----- commands/utility/optout.js | 6 +++--- commands/utility/vid2gif.js | 3 +++ 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/commands/admin/autoresponse.js b/commands/admin/autoresponse.js index b16e3b6a..13784356 100644 --- a/commands/admin/autoresponse.js +++ b/commands/admin/autoresponse.js @@ -19,13 +19,13 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('yes') + .setCustomId(`yes${interaction.user.id}`) .setLabel('Yes') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('no') + .setCustomId(`no${interaction.user.id}`) .setLabel('No') .setStyle(ButtonStyle.Danger), ); @@ -36,7 +36,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'yes') { + if (interactionMenu.customId === `yes${interaction.user.id}`) { const body = { serverID: interaction.guild.id, stat: 'disable' }; await db.autoresponseStat.update(body, { where: { serverID: interaction.guild.id } }); return interaction.editReply({ content: 'Auto response has been disabled.', ephemeral: true }); diff --git a/commands/admin/bye.js b/commands/admin/bye.js index 787ee443..c905ca00 100644 --- a/commands/admin/bye.js +++ b/commands/admin/bye.js @@ -25,19 +25,19 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('edit') + .setCustomId(`edit${interaction.user.id}`) .setLabel('Edit') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('remove') + .setCustomId(`remove${interaction.user.id}`) .setLabel('Remove') .setStyle(ButtonStyle.Danger), ) .addComponents( new ButtonBuilder() - .setCustomId('nothing') + .setCustomId(`nothing${interaction.user.id}`) .setLabel('Do nothing') .setStyle(ButtonStyle.Secondary), ); @@ -48,7 +48,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'edit') { + if (interactionMenu.customId === `edit${interaction.user.id}`) { if (!args.message) { return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true }); } @@ -56,7 +56,7 @@ export default { await db.leaveChannel.update(body, { where: { guildID: interaction.guild.id } }); return interaction.editReply({ content: `The leave message has been set to ${args.message}`, ephemeral: true }); } - else if (interactionMenu.customId === 'remove') { + else if (interactionMenu.customId === `remove${interaction.user.id}`) { db.leaveChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } }); return interaction.editReply({ content: 'The leave message has been deleted.', ephemeral: true }); } diff --git a/commands/admin/quotation.js b/commands/admin/quotation.js index 422eb6f3..f768a5ea 100644 --- a/commands/admin/quotation.js +++ b/commands/admin/quotation.js @@ -19,13 +19,13 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('yes') + .setCustomId(`yes${interaction.user.id}`) .setLabel('Yes') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('no') + .setCustomId(`no${interaction.user.id}`) .setLabel('No') .setStyle(ButtonStyle.Danger), ); @@ -36,7 +36,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'yes') { + if (interactionMenu.customId === `yes${interaction.user.id}`) { const body = { serverID: interaction.guild.id, stat: 'disable' }; await db.quotationStat.update(body, { where: { serverID: interaction.guild.id } }); return interaction.editReply({ content: 'Quotation has been disabled.', ephemeral: true }); diff --git a/commands/admin/welcome.js b/commands/admin/welcome.js index a49dd5fc..351597bf 100644 --- a/commands/admin/welcome.js +++ b/commands/admin/welcome.js @@ -26,19 +26,19 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('edit') + .setCustomId(`edit${interaction.user.id}`) .setLabel('Edit') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('remove') + .setCustomId(`remove${interaction.user.id}`) .setLabel('Remove') .setStyle(ButtonStyle.Danger), ) .addComponents( new ButtonBuilder() - .setCustomId('nothing') + .setCustomId(`nothing${interaction.user.id}`) .setLabel('Do nothing') .setStyle(ButtonStyle.Secondary), ); @@ -49,7 +49,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'edit') { + if (interactionMenu.customId === `edit${interaction.user.id}`) { if (!args.message) { return interaction.reply({ content: 'You need to input a message for me to edit!', ephemeral: true }); } @@ -57,7 +57,7 @@ export default { await db.joinChannel.update(body, { where: { guildID: interaction.guild.id } }); return interaction.editReply({ content: `The join message has been set to ${args.message}`, ephemeral: true }); } - else if (interactionMenu.customId === 'remove') { + else if (interactionMenu.customId === `remove${interaction.user.id}`) { db.joinChannel.destroy({ where: { guildID: interaction.guild.id, channelID: interaction.channel.id } }); return interaction.editReply({ content: 'The join message has been deleted.', ephemeral: true }); } diff --git a/commands/owner/ublacklist.js b/commands/owner/ublacklist.js index 1c0d5640..94a0f5c0 100644 --- a/commands/owner/ublacklist.js +++ b/commands/owner/ublacklist.js @@ -41,13 +41,13 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('yes') + .setCustomId(`yes${interaction.user.id}`) .setLabel('Yes') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('no') + .setCustomId(`no${interaction.user.id}`) .setLabel('No') .setStyle(ButtonStyle.Danger), ); @@ -58,7 +58,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'yes') { + if (interactionMenu.customId === `yes${interaction.user.id}`) { Blacklists.destroy({ where: { type:command, uid:userid } }); return interaction.editReply(`The following ID have been unblacklisted from ${command}: ${userid}`); } diff --git a/commands/utility/download.js b/commands/utility/download.js index 40e9e70c..a788f9cc 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -90,7 +90,7 @@ export default { const row = new ActionRowBuilder() .addComponents( new SelectMenuBuilder() - .setCustomId('downloadQuality') + .setCustomId(`downloadQuality${interaction.user.id}`) .setPlaceholder('Nothing selected') .setMinValues(1) .setMaxValues(2) @@ -103,7 +103,7 @@ export default { client.on('interactionCreate', async (interactionMenu) => { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isSelectMenu()) return; - if (interactionMenu.customId === 'downloadQuality') { + if (interactionMenu.customId === `downloadQuality${interaction.user.id}`) { await interactionMenu.deferReply({ ephemeral: false }); download(url, interactionMenu, interaction); } @@ -121,7 +121,7 @@ async function download(url, interaction, originalInteraction) { .setAuthor({ name: `Downloaded by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL(), url: url }) .setFooter({ text: `You can get the original video by clicking on the "Downloaded by ${interaction.user.tag}" message!` }); - if (interaction.customId === 'downloadQuality') { + if (interaction.customId === `downloadQuality${interaction.user.id}`) { format = interaction.values[0]; if (interaction.values[1]) format += '+' + interaction.values[1]; } @@ -148,7 +148,7 @@ async function download(url, interaction, originalInteraction) { const row = new ActionRowBuilder() .addComponents( new SelectMenuBuilder() - .setCustomId('preset') + .setCustomId(`preset${interaction.user.id}`) .setPlaceholder('Nothing selected') .addOptions(options), ); @@ -158,7 +158,7 @@ async function download(url, interaction, originalInteraction) { client.on('interactionCreate', async (interactionMenu) => { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isSelectMenu()) return; - if (interactionMenu.customId === 'preset') { + if (interactionMenu.customId === `preset${interaction.user.id}`) { await interactionMenu.deferReply({ ephemeral: false }); compress(file, interactionMenu, Embed); if (interaction.isMessage) cleanUp(); diff --git a/commands/utility/optout.js b/commands/utility/optout.js index e1548d20..535227ec 100644 --- a/commands/utility/optout.js +++ b/commands/utility/optout.js @@ -18,13 +18,13 @@ export default { const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() - .setCustomId('yes') + .setCustomId(`yes${interaction.user.id}`) .setLabel('Yes') .setStyle(ButtonStyle.Primary), ) .addComponents( new ButtonBuilder() - .setCustomId('no') + .setCustomId(`no${interaction.user.id}`) .setLabel('No') .setStyle(ButtonStyle.Danger), ); @@ -35,7 +35,7 @@ export default { if (interaction.user !== interactionMenu.user) return; if (!interactionMenu.isButton) return; interactionMenu.update({ components: [] }); - if (interactionMenu.customId === 'yes') { + if (interactionMenu.customId === `yes${interaction.user.id}`) { await db.optout.destroy({ where: { userID: interaction.user.id } }); return interaction.editReply('You have successfully been opt in'); } diff --git a/commands/utility/vid2gif.js b/commands/utility/vid2gif.js index 05456142..7eb85a57 100644 --- a/commands/utility/vid2gif.js +++ b/commands/utility/vid2gif.js @@ -4,6 +4,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { exec } from 'node:child_process'; +const { NODE_ENV } = process.env; export default { @@ -68,6 +69,7 @@ async function gifski(output, input) { if (stderr) { console.error(stderr); } + console.log(NODE_ENV === 'development' ? stdout : null); resolve(); }); }); @@ -82,6 +84,7 @@ async function gifsicle(input, output) { if (stderr) { console.error(stderr); } + console.log(NODE_ENV === 'development' ? stdout : null); resolve(); }); });