user command support

This commit is contained in:
derpystuff 2024-03-19 17:28:37 +01:00
parent af5a7f4252
commit 86936dc100
14 changed files with 710 additions and 11 deletions

View file

@ -9,9 +9,16 @@ 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;
this.editOrReply = data.context.editOrReply.bind(data.context);
this.targetUser = data.targetUser || this.message?.author?.id || data.context?.user?.id;
this.isInteractionPaginator = false;
this.editOrReply;
if(data.context.editOrReply) this.editOrReply = data.context.editOrReply.bind(data.context);
if(data.context.editOrRespond){
this.editOrReply = data.context.editOrRespond.bind(data.context);
this.isInteractionPaginator = true;
}
}
static asMessage(ctx) {
@ -39,12 +46,13 @@ module.exports = class BasePaginator extends EventEmitter {
}
async update(data) {
if(this.isInteractionPaginator) return;
if (this.isShared) {
for (const m of this.commandMessage.values()) {
if(!m.deleted) await m.edit(data);
}
} else if (this.commandMessage) {
if(!this.commandMessage.deleted) this.commandMessage.edit(data);
if(!this.commandMessage.deleted) this.commandMessage.edit(data).catch((e)=>{});
}
}

View file

@ -153,7 +153,7 @@ module.exports = class Paginator {
if (!(l instanceof InteractionPaginator)) continue;
if (!l.commandMessage) continue;
if (l.isCommandMessage(data.context.message.id)) {
if (data.context.message?.id && l.isCommandMessage(data.context.message.id)) {
listener = l
}
}

View file

@ -164,7 +164,10 @@ module.exports.formatPaginationEmbeds = function(embeds){
formatted.push(ne)
} else if (e.embeds){
ne.embeds = e.embeds.map((se)=>{
se.footer.text = se.footer.text + ` • Page ${i}/${l}`
if(se.footer) se.footer.text = se.footer.text + ` • Page ${i}/${l}`
else se.footer = {
text: `Page ${i}/${l}`
}
return se;
})