Fixed speed frame removal delay bug, allow extending pagination timeout
This commit is contained in:
parent
26741e8c6c
commit
7536352858
4 changed files with 15 additions and 3 deletions
|
@ -8,11 +8,12 @@ class InteractionCollector extends EventEmitter {
|
|||
this.type = type;
|
||||
this.ended = false;
|
||||
this.bot = client;
|
||||
this.timeout = timeout;
|
||||
this.listener = async (interaction) => {
|
||||
await this.verify(interaction);
|
||||
};
|
||||
this.bot.on("interactionCreate", this.listener);
|
||||
setTimeout(() => this.stop("time"), timeout);
|
||||
this.end = setTimeout(() => this.stop("time"), timeout);
|
||||
}
|
||||
|
||||
async verify(interaction) {
|
||||
|
@ -22,6 +23,11 @@ class InteractionCollector extends EventEmitter {
|
|||
return true;
|
||||
}
|
||||
|
||||
extend() {
|
||||
clearTimeout(this.end);
|
||||
this.end = setTimeout(() => this.stop("time"), this.timeout);
|
||||
}
|
||||
|
||||
stop(reason) {
|
||||
if (this.ended) return;
|
||||
this.ended = true;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import MessageCollector from "./awaitmessages.js";
|
||||
import InteractionCollector from "./awaitinteractions.js";
|
||||
import { ComponentInteraction } from "eris";
|
||||
|
||||
|
@ -73,11 +72,13 @@ export default async (client, message, pages, timeout = 120000) => {
|
|||
await interaction.deferUpdate();
|
||||
page = page > 0 ? --page : pages.length - 1;
|
||||
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||
interactionCollector.extend();
|
||||
break;
|
||||
case "forward":
|
||||
await interaction.deferUpdate();
|
||||
page = page + 1 < pages.length ? ++page : 0;
|
||||
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||
interactionCollector.extend();
|
||||
break;
|
||||
case "jump":
|
||||
await interaction.deferUpdate();
|
||||
|
@ -86,6 +87,7 @@ export default async (client, message, pages, timeout = 120000) => {
|
|||
newComponents.components[0].components[index].disabled = true;
|
||||
}
|
||||
currentPage = await currentPage.edit(newComponents);
|
||||
interactionCollector.extend();
|
||||
const jumpComponents = {
|
||||
components: [{
|
||||
type: 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue