defer reply on unsubscribe command; Possible fix to super delayed response
Some checks are pending
ptero-push / build (push) Waiting to run
Some checks are pending
ptero-push / build (push) Waiting to run
This commit is contained in:
parent
e2596c4443
commit
b3cc4887c2
17
index.js
17
index.js
|
@ -865,39 +865,40 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
interaction.reply({ content: "Invalid room", ephemeral: true });
|
interaction.reply({ content: "Invalid room", ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
interaction.deferReply({ ephemeral: true });
|
||||||
if (interaction.inGuild()) {
|
if (interaction.inGuild()) {
|
||||||
// Check if subbed
|
// Check if subbed
|
||||||
db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => {
|
db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
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) {
|
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) => {
|
db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
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 {
|
} else {
|
||||||
db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => {
|
db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
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) {
|
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) => {
|
db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
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 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue