diff --git a/.env.example b/.env.example index 8419bab..41a21d9 100644 --- a/.env.example +++ b/.env.example @@ -45,5 +45,5 @@ TMP_DOMAIN= # Port for serving metrics. Metrics served are compatible with Prometheus. METRICS= -# Set this to true if you want to use the image API +# Set this to true if you want to use the external image API script, located in api/index.js API=false diff --git a/natives/speed.cc b/natives/speed.cc index 30ee6e0..1beb7c5 100644 --- a/natives/speed.cc +++ b/natives/speed.cc @@ -94,6 +94,10 @@ Napi::Value Speed(const Napi::CallbackInfo &info) { for (list::iterator i = frames.begin(); i != frames.end(); ++i) { int index = distance(frames.begin(), i); + if (index >= (int)old_delays.size()) { + old_delays.resize(index+1); + old_delays[index] = old_delays[index-1]; + } i->animationDelay(old_delays[index]); } diff --git a/utils/pagination/awaitinteractions.js b/utils/pagination/awaitinteractions.js index 237afcf..39087d6 100644 --- a/utils/pagination/awaitinteractions.js +++ b/utils/pagination/awaitinteractions.js @@ -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; diff --git a/utils/pagination/pagination.js b/utils/pagination/pagination.js index c1b649f..b129f49 100644 --- a/utils/pagination/pagination.js +++ b/utils/pagination/pagination.js @@ -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,