forked from Galactic/galactic-bot
move prompt interaction to invokerwrapper
This commit is contained in:
parent
8b2c25085b
commit
a5d0479d4e
@ -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;
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user