mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 23:23:08 -04:00
revert certain paginator changes
This commit is contained in:
parent
0470db6a64
commit
b9248e6aad
3 changed files with 19 additions and 19 deletions
|
@ -9,17 +9,9 @@ module.exports = class BasePaginator extends EventEmitter {
|
|||
this.commandMessage = data.commandMessage || null;
|
||||
this.pages = data.pages;
|
||||
this.index = 0;
|
||||
this.targetUser = data.targetUser || this.message?.author?.id || data.context?.user?.id;
|
||||
|
||||
this.waitingForPage = null;
|
||||
this.targetUser = data.targetUser || this.message.author.id;
|
||||
|
||||
this.editOrReply = data.context.editOrReply?.bind(data.context);
|
||||
|
||||
// Support application command context
|
||||
if(data.context.editOrRespond) {
|
||||
this.editOrRespond = data.context.editOrRespond.bind(data.context)
|
||||
this.editOrReply = (d) => this.editOrRespond(d)
|
||||
}
|
||||
this.editOrReply = data.context.editOrReply.bind(data.context);
|
||||
}
|
||||
|
||||
static asMessage(ctx) {
|
||||
|
@ -158,4 +150,4 @@ module.exports = class BasePaginator extends EventEmitter {
|
|||
this.client.activeListeners.splice(targetIndex, 1);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
8
labscore/paginator/structures/InteractionPaginator.js
Normal file
8
labscore/paginator/structures/InteractionPaginator.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
const BasePaginator = require("./BasePaginator");
|
||||
|
||||
module.exports = class InteractionPaginator extends BasePaginator {
|
||||
constructor(client, data) {
|
||||
super(client, data);
|
||||
this.waitingForPage = null;
|
||||
}
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
const BasePaginator = require("./BasePaginator");
|
||||
const InteractionPaginator = require("./InteractionPaginator");
|
||||
const assert = require("assert");
|
||||
|
||||
const { Constants, Utils } = require('detritus-client');
|
||||
const { Constants, Utils } = require('detritus-client')
|
||||
const { Components } = Utils
|
||||
const { InteractionCallbackTypes } = Constants
|
||||
|
||||
|
@ -44,7 +44,7 @@ module.exports = class Paginator {
|
|||
if (!allowedEvents.has(event)) return;
|
||||
|
||||
for (const listener of this.activeListeners) {
|
||||
if (!(listener instanceof BasePaginator)) continue;
|
||||
if (!(listener instanceof InteractionPaginator)) continue;
|
||||
if (!listener.commandMessage) continue;
|
||||
|
||||
if (event === "MESSAGE_CREATE" &&
|
||||
|
@ -60,7 +60,7 @@ module.exports = class Paginator {
|
|||
async handleButtonEvent(context) {
|
||||
let listener;
|
||||
for (const l of this.activeListeners) {
|
||||
if (!(l instanceof BasePaginator)) continue;
|
||||
if (!(l instanceof InteractionPaginator)) continue;
|
||||
if (!l.commandMessage) continue;
|
||||
if (l.isCommandMessage(context.message.id)) {
|
||||
listener = l
|
||||
|
@ -150,17 +150,16 @@ module.exports = class Paginator {
|
|||
// Check if a paginator exists, if it does kill the old one
|
||||
let listener;
|
||||
for (const l of this.activeListeners) {
|
||||
if (!(l instanceof BasePaginator)) continue;
|
||||
if (!(l instanceof InteractionPaginator)) continue;
|
||||
if (!l.commandMessage) continue;
|
||||
|
||||
if (data.context.message?.id && l.isCommandMessage(data.context.message?.id)) {
|
||||
if (l.isCommandMessage(data.context.message.id)) {
|
||||
listener = l
|
||||
}
|
||||
}
|
||||
|
||||
if(listener) await listener.stop()
|
||||
|
||||
const instance = new BasePaginator(this, data);
|
||||
const instance = new InteractionPaginator(this, data);
|
||||
this.activeListeners.push(instance);
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -183,3 +182,4 @@ module.exports = class Paginator {
|
|||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue