From 19284b1d09d6961a3697c1aadb2095813e8c8041 Mon Sep 17 00:00:00 2001 From: Charlie Laabs Date: Sun, 9 Jan 2022 18:05:25 -0600 Subject: [PATCH] Fix training reply webhook timeout --- src/index.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index a6c002c..c517735 100644 --- a/src/index.ts +++ b/src/index.ts @@ -314,7 +314,7 @@ async function saveGuildMessageHistory( limit: PAGE_SIZE, }); } catch (err) { - L.error({ before: oldestMessageID, limit: PAGE_SIZE }, 'Error retreiving messages'); + L.error(`Error retreiving messages before ${oldestMessageID}`); L.error(err); break; // Give up on this channel } @@ -341,10 +341,7 @@ async function saveGuildMessageHistory( limit: PAGE_SIZE, }); } catch (err) { - L.error( - { before: oldestThreadMessageID, limit: PAGE_SIZE }, - 'Error retreiving thread messages' - ); + L.error(`Error retreiving thread messages before ${oldestThreadMessageID}`); L.error(err); break; // Give up on this thread } @@ -810,8 +807,10 @@ client.on('interactionCreate', async (interaction) => { } } else if (interaction.commandName === trainCommand.name) { await interaction.deferReply(); + const reply = (await interaction.fetchReply()) as Discord.Message; // Must fetch the reply ASAP const responseMessage = await saveGuildMessageHistory(interaction); - await interaction.followUp({ content: responseMessage }); + // Send a message in reply to the reply to avoid the 15 minute webhook token timeout + await reply.reply({ content: responseMessage }); } } else if (interaction.isSelectMenu()) { if (interaction.customId === 'listen-modify-select') {