Fix training reply webhook timeout

This commit is contained in:
Charlie Laabs
2022-01-09 18:05:25 -06:00
parent f9fbba204a
commit 19284b1d09

View File

@@ -314,7 +314,7 @@ async function saveGuildMessageHistory(
limit: PAGE_SIZE, limit: PAGE_SIZE,
}); });
} catch (err) { } catch (err) {
L.error({ before: oldestMessageID, limit: PAGE_SIZE }, 'Error retreiving messages'); L.error(`Error retreiving messages before ${oldestMessageID}`);
L.error(err); L.error(err);
break; // Give up on this channel break; // Give up on this channel
} }
@@ -341,10 +341,7 @@ async function saveGuildMessageHistory(
limit: PAGE_SIZE, limit: PAGE_SIZE,
}); });
} catch (err) { } catch (err) {
L.error( L.error(`Error retreiving thread messages before ${oldestThreadMessageID}`);
{ before: oldestThreadMessageID, limit: PAGE_SIZE },
'Error retreiving thread messages'
);
L.error(err); L.error(err);
break; // Give up on this thread break; // Give up on this thread
} }
@@ -810,8 +807,10 @@ client.on('interactionCreate', async (interaction) => {
} }
} else if (interaction.commandName === trainCommand.name) { } else if (interaction.commandName === trainCommand.name) {
await interaction.deferReply(); await interaction.deferReply();
const reply = (await interaction.fetchReply()) as Discord.Message; // Must fetch the reply ASAP
const responseMessage = await saveGuildMessageHistory(interaction); 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()) { } else if (interaction.isSelectMenu()) {
if (interaction.customId === 'listen-modify-select') { if (interaction.customId === 'listen-modify-select') {