From a5d0479d4ee3bee75e4646656849f4a5433660a0 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 6 Sep 2022 13:11:35 +0300 Subject: [PATCH] move prompt interaction to invokerwrapper --- .../client/wrappers/InteractionWrapper.js | 34 +++++++++---------- .../client/wrappers/InvokerWrapper.js | 20 +++++++++++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/structure/client/wrappers/InteractionWrapper.js b/src/structure/client/wrappers/InteractionWrapper.js index 807c1d2..a8cad78 100644 --- a/src/structure/client/wrappers/InteractionWrapper.js +++ b/src/structure/client/wrappers/InteractionWrapper.js @@ -69,24 +69,24 @@ class InteractionWrapper { return this.interaction.editReply(options); } - async promptInteraction(opts = {}, time = 30) { - if (!opts.components) throw new Error('Missing components. Use promptMessage'); - let message = null; - if (this.replied || this.deferred) message = await this.editReply(opts); - else message = await this.reply(opts); + // async promptInteraction(opts = {}, time = 30) { + // if (!opts.components) throw new Error('Missing components. Use promptMessage'); + // let message = null; + // if (this.replied || this.deferred) message = await this.editReply(opts); + // else message = await this.reply(opts); - return new Promise((resolve) => { - message.createMessageComponentCollector({ - time: time*1000, - componentType: opts.componentType || 'BUTTON', - max: 1, - filter: (i) => i.user.id === this.user.id - }).on('collect', resolve) - .on('end', (collected) => { - if (!collected.size) resolve(null); - }); - }); - } + // return new Promise((resolve) => { + // message.createMessageComponentCollector({ + // time: time*1000, + // componentType: opts.componentType || 'BUTTON', + // max: 1, + // filter: (i) => i.user.id === this.user.id + // }).on('collect', resolve) + // .on('end', (collected) => { + // if (!collected.size) resolve(null); + // }); + // }); + // } replyEmbed(embed) { if (!embed.color) embed.color = EmbedDefaultColor; diff --git a/src/structure/client/wrappers/InvokerWrapper.js b/src/structure/client/wrappers/InvokerWrapper.js index d940dac..90d3935 100644 --- a/src/structure/client/wrappers/InvokerWrapper.js +++ b/src/structure/client/wrappers/InvokerWrapper.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require("@discordjs/builders"); +const { ComponentType } = require("discord.js"); const { Emojis, Constants } = require("../../../constants"); const MessageWrapper = require("./MessageWrapper"); @@ -135,6 +136,25 @@ class InvokerWrapper { }); } + async promptInteraction(opts = {}, time = 30) { + if (!opts.components) throw new Error('Missing components. Use promptMessage'); + let message = null; + if (this.replied || this.deferred) message = await this.editReply(opts); + else message = await this.reply(opts); + + return new Promise((resolve) => { + message.createMessageComponentCollector({ + time: time * 1000, + componentType: opts.componentType || ComponentType.Button, + max: 1, + filter: (i) => i.user.id === this.user.id + }).on('collect', resolve) + .on('end', (collected) => { + if (!collected.size) resolve(null); + }); + }); + } + async reply(options = {}) { if (typeof options === 'string') options = { content: options };