utils.selectionMessage: fix race condition by adding clever id checking

This commit is contained in:
Cynthia Foxwell 2021-08-30 13:28:20 -06:00
parent c2bed24794
commit c3e94cd593

View file

@ -174,7 +174,7 @@ async function selectionMessage(msg, heading, options, timeout = 30000) {
components: [
{
type: 3,
custom_id: "selection",
custom_id: msg.id,
options: [],
},
],
@ -212,7 +212,8 @@ async function selectionMessage(msg, heading, options, timeout = 30000) {
if (
user.id == msg.author.id &&
interaction.channel_id == msg.channel.id
interaction.channel_id == msg.channel.id &&
interaction.message.components[0].components[0].custom_id == msg.id
) {
if (interaction.data.custom_id == "cancel") {
hf.events.remove("unknown", `selection.${msg.id}`);