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
|
@ -45,5 +45,5 @@ TMP_DOMAIN=
|
||||||
# Port for serving metrics. Metrics served are compatible with Prometheus.
|
# Port for serving metrics. Metrics served are compatible with Prometheus.
|
||||||
METRICS=
|
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
|
API=false
|
||||||
|
|
|
@ -94,6 +94,10 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
for (list<Image>::iterator i = frames.begin(); i != frames.end(); ++i) {
|
for (list<Image>::iterator i = frames.begin(); i != frames.end(); ++i) {
|
||||||
int index = distance(frames.begin(), 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]);
|
i->animationDelay(old_delays[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,12 @@ class InteractionCollector extends EventEmitter {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.ended = false;
|
this.ended = false;
|
||||||
this.bot = client;
|
this.bot = client;
|
||||||
|
this.timeout = timeout;
|
||||||
this.listener = async (interaction) => {
|
this.listener = async (interaction) => {
|
||||||
await this.verify(interaction);
|
await this.verify(interaction);
|
||||||
};
|
};
|
||||||
this.bot.on("interactionCreate", this.listener);
|
this.bot.on("interactionCreate", this.listener);
|
||||||
setTimeout(() => this.stop("time"), timeout);
|
this.end = setTimeout(() => this.stop("time"), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
async verify(interaction) {
|
async verify(interaction) {
|
||||||
|
@ -22,6 +23,11 @@ class InteractionCollector extends EventEmitter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend() {
|
||||||
|
clearTimeout(this.end);
|
||||||
|
this.end = setTimeout(() => this.stop("time"), this.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
stop(reason) {
|
stop(reason) {
|
||||||
if (this.ended) return;
|
if (this.ended) return;
|
||||||
this.ended = true;
|
this.ended = true;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import MessageCollector from "./awaitmessages.js";
|
|
||||||
import InteractionCollector from "./awaitinteractions.js";
|
import InteractionCollector from "./awaitinteractions.js";
|
||||||
import { ComponentInteraction } from "eris";
|
import { ComponentInteraction } from "eris";
|
||||||
|
|
||||||
|
@ -73,11 +72,13 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
page = page > 0 ? --page : pages.length - 1;
|
page = page > 0 ? --page : pages.length - 1;
|
||||||
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||||
|
interactionCollector.extend();
|
||||||
break;
|
break;
|
||||||
case "forward":
|
case "forward":
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
page = page + 1 < pages.length ? ++page : 0;
|
page = page + 1 < pages.length ? ++page : 0;
|
||||||
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
currentPage = await currentPage.edit(Object.assign(pages[page], options));
|
||||||
|
interactionCollector.extend();
|
||||||
break;
|
break;
|
||||||
case "jump":
|
case "jump":
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
|
@ -86,6 +87,7 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
newComponents.components[0].components[index].disabled = true;
|
newComponents.components[0].components[index].disabled = true;
|
||||||
}
|
}
|
||||||
currentPage = await currentPage.edit(newComponents);
|
currentPage = await currentPage.edit(newComponents);
|
||||||
|
interactionCollector.extend();
|
||||||
const jumpComponents = {
|
const jumpComponents = {
|
||||||
components: [{
|
components: [{
|
||||||
type: 1,
|
type: 1,
|
||||||
|
|
Loading…
Reference in a new issue