From b3cc4887c2396a5fbb2fe4192fdda31b086786ad Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Tue, 27 May 2025 20:34:13 -0600 Subject: [PATCH] defer reply on unsubscribe command; Possible fix to super delayed response --- index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index e3925b9..7b8b626 100644 --- a/index.js +++ b/index.js @@ -865,39 +865,40 @@ discord.on("interactionCreate", async (interaction) => { interaction.reply({ content: "Invalid room", ephemeral: true }); return; } + interaction.deferReply({ ephemeral: true }); if (interaction.inGuild()) { // Check if subbed db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => { if (err) { console.error(err.message); - interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + interaction.editReply({ content: "Failed to unsubscribe from room", ephemeral: true }); } if (!row) { - return interaction.reply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + return interaction.editReply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); } db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err) => { if (err) { console.error(err.message); - interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + interaction.editReply({ content: "Failed to unsubscribe from room", ephemeral: true }); } - interaction.reply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); + interaction.editReply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); }); }); } else { db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => { if (err) { console.error(err.message); - interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + interaction.editReply({ content: "Failed to unsubscribe from room", ephemeral: true }); } if (!row) { - return interaction.reply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + return interaction.editReply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); } db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err) => { if (err) { console.error(err.message); - interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + interaction.editReply({ content: "Failed to unsubscribe from room", ephemeral: true }); } - interaction.reply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); + interaction.editReply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); }); }); }