Catch some extra message deletes

This commit is contained in:
Essem 2022-03-15 18:47:23 -05:00
parent db068cee60
commit e01eaa4876
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C

View file

@ -120,7 +120,11 @@ export default async (client, message, pages, timeout = 120000) => {
let ended = false; let ended = false;
dropdownCollector.on("interaction", async (response) => { dropdownCollector.on("interaction", async (response) => {
if (response.data.custom_id !== "seekDropdown") return; if (response.data.custom_id !== "seekDropdown") return;
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete(); try {
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
} catch {
// no-op
}
page = Number(response.data.values[0]); page = Number(response.data.values[0]);
currentPage = await currentPage.edit(Object.assign(pages[page], options, components)); currentPage = await currentPage.edit(Object.assign(pages[page], options, components));
ended = true; ended = true;
@ -128,7 +132,11 @@ export default async (client, message, pages, timeout = 120000) => {
}); });
dropdownCollector.once("end", async () => { dropdownCollector.once("end", async () => {
if (ended) return; if (ended) return;
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete(); try {
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
} catch {
// no-op
}
currentPage = await currentPage.edit(Object.assign(pages[page], options, components)); currentPage = await currentPage.edit(Object.assign(pages[page], options, components));
}); });
}).catch(error => { }).catch(error => {