From 116ed94ca3c10e86c6dc02fb93e75e1b0be02cb1 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Sat, 16 Jan 2021 23:46:07 -0600 Subject: [PATCH] Attempt to fix a crash with pagination reaction removal --- utils/pagination/pagination.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/pagination/pagination.js b/utils/pagination/pagination.js index 6c073cd..056aa15 100644 --- a/utils/pagination/pagination.js +++ b/utils/pagination/pagination.js @@ -5,7 +5,6 @@ const client = require("../client.js"); module.exports = async (message, pages, timeout = 120000) => { const manageMessages = message.channel.guild && (message.channel.guild.members.get(client.user.id).permission.has("manageMessages") || message.channel.permissionsOf(client.user.id).has("manageMessages")) ? true : false; let page = 0; - let deleted = false; const currentPage = await message.channel.createMessage(pages[page]); const emojiList = ["◀", "🔢", "▶", "🗑"]; for (const emoji of emojiList) { @@ -42,7 +41,6 @@ module.exports = async (message, pages, timeout = 120000) => { if (manageMessages) msg.removeReaction("▶", userID); break; case "🗑": - deleted = true; reactionCollector.emit("end"); if (currentPage.channel.messages.get(currentPage.id)) currentPage.delete(); return; @@ -52,7 +50,9 @@ module.exports = async (message, pages, timeout = 120000) => { } }); reactionCollector.once("end", () => { - if (!deleted && manageMessages) currentPage.removeReactions(); + if (message.channel.messages.get(currentPage.id) && manageMessages) { + currentPage.removeReactions(); + } }); return currentPage; };