mirror of
https://github.com/citra-emu/discord-bot.git
synced 2025-01-28 23:40:59 +00:00
Update specs.ts
Update the footer of the embed with context when the buttons are disabled
This commit is contained in:
parent
14e756f29f
commit
985493edee
|
@ -62,15 +62,24 @@ function createEmbed(device: any, searchQuery: string, results: number, index: n
|
|||
|
||||
// End listener function to disable buttons after message collector times out
|
||||
function addEndListener(collector, previous, next, row, sentMessage) {
|
||||
let endListenerAdded = false
|
||||
let endListenerAdded = false;
|
||||
|
||||
// Function to be called when the collector ends to disable buttons and update message.
|
||||
const endListener = async () => {
|
||||
previous.setDisabled(true);
|
||||
next.setDisabled(true);
|
||||
await sentMessage.edit({ components: [row] }).catch(logger.error);
|
||||
await sentMessage.edit({ components: [row] }).catch(console.error);
|
||||
|
||||
// Update footer text on timeout
|
||||
const newEmbed = new EmbedBuilder(sentMessage.embeds[0])
|
||||
.setFooter({ text: "Interaction timeout: Buttons disabled." });
|
||||
await sentMessage.edit({ embeds: [newEmbed] });
|
||||
|
||||
collector.stop();
|
||||
};
|
||||
if (!endListenerAdded) {
|
||||
|
||||
// Add the end listener only if it hasn't already been added.
|
||||
if (!endListenerAdded) {
|
||||
collector.on('end', endListener);
|
||||
endListenerAdded = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue