mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-17 10:27:05 -04:00
[fix] paginator editing works properly now
This commit is contained in:
parent
a68b840af7
commit
41721f941f
13 changed files with 32 additions and 37 deletions
|
@ -1,5 +1,4 @@
|
|||
const { Constants, ClusterClient, CommandClient } = require('detritus-client');
|
||||
//const { createPaginator } = require('./paginator')
|
||||
const Paginator = require('./paginator').PaginatorCluster
|
||||
|
||||
// Create client
|
||||
|
@ -40,12 +39,6 @@ const paginator = new Paginator(cluster, {
|
|||
});
|
||||
await commandClient.addMultipleIn('../commands/message/');
|
||||
await commandClient.run()
|
||||
|
||||
//commandClient.on('commandDelete', async ({reply}) => {
|
||||
// if (reply){
|
||||
// reply.delete();
|
||||
// }
|
||||
//});
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ module.exports = class BasePaginator extends EventEmitter {
|
|||
constructor(client, data) {
|
||||
super();
|
||||
this.client = client;
|
||||
this.message = BasePaginator.asMessage(data.message);
|
||||
this.message = BasePaginator.asMessage(data.context);
|
||||
this.commandMessage = data.commandMessage || null;
|
||||
this.pages = data.pages;
|
||||
this.index = 0;
|
||||
this.targetUser = data.targetUser || this.message.author.id;
|
||||
|
||||
// TODO: use editOrReply, kill old paginator if it exists
|
||||
this.editOrReply = (data.message.editOrReply || data.message.reply).bind(data.message);
|
||||
this.editOrReply = data.context.editOrReply.bind(data.context);
|
||||
}
|
||||
|
||||
static asMessage(ctx) {
|
||||
|
@ -53,6 +53,8 @@ module.exports = class BasePaginator extends EventEmitter {
|
|||
// Create Components
|
||||
let msg = this.pages[this.index];
|
||||
msg.components = await this.client.components(this)
|
||||
if(!msg.message_reference) msg.reference = true
|
||||
if(!msg.allowedMentions) msg.allowedMentions = {parse: [], repliedUser: false}
|
||||
return this.commandMessage = await this.editOrReply(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,10 +150,21 @@ module.exports = class Paginator {
|
|||
if (this.pageNumber && Array.isArray(data.pages)) {
|
||||
for (let i = 0; i < data.pages.length; ++i) {
|
||||
const element = data.pages[i];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a paginator exists, if it does kill the old one
|
||||
let listener;
|
||||
for (const l of this.activeListeners) {
|
||||
if (!(l instanceof InteractionPaginator)) continue;
|
||||
if (!l.commandMessage) continue;
|
||||
|
||||
if (l.isCommandMessage(data.context.message.id)) {
|
||||
listener = l
|
||||
}
|
||||
}
|
||||
if(listener) await listener.stop()
|
||||
|
||||
const instance = new InteractionPaginator(this, data);
|
||||
this.activeListeners.push(instance);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = class PaginatorCluster {
|
|||
}
|
||||
|
||||
createPaginator(data) {
|
||||
const targetPaginator = this.findOrSetPaginator(data.message.client);
|
||||
const targetPaginator = this.findOrSetPaginator(data.context.client);
|
||||
|
||||
return targetPaginator.createPaginator(data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue