mirror of
https://github.com/citra-emu/discord-bot.git
synced 2025-01-30 18:00:58 +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,14 +62,23 @@ function createEmbed(device: any, searchQuery: string, results: number, index: n
|
||||||
|
|
||||||
// End listener function to disable buttons after message collector times out
|
// End listener function to disable buttons after message collector times out
|
||||||
function addEndListener(collector, previous, next, row, sentMessage) {
|
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.
|
// Function to be called when the collector ends to disable buttons and update message.
|
||||||
const endListener = async () => {
|
const endListener = async () => {
|
||||||
previous.setDisabled(true);
|
previous.setDisabled(true);
|
||||||
next.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();
|
collector.stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add the end listener only if it hasn't already been added.
|
||||||
if (!endListenerAdded) {
|
if (!endListenerAdded) {
|
||||||
collector.on('end', endListener);
|
collector.on('end', endListener);
|
||||||
endListenerAdded = true;
|
endListenerAdded = true;
|
||||||
|
|
Loading…
Reference in a new issue