Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove remnants of awaitMessageComponentInteractions #5783

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/structures/DMChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DMChannel extends Channel {
createMessageCollector() {}
awaitMessages() {}
createMessageComponentInteractionCollector() {}
awaitMessageComponentInteractions() {}
awaitMessageComponentInteraction() {}
// Doesn't work on DM channels; bulkDelete() {}
}

Expand Down
31 changes: 13 additions & 18 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,30 +440,25 @@ class Message extends Base {
}

/**
* An object containing the same properties as CollectorOptions, but a few more:
* @typedef {MessageComponentInteractionCollectorOptions} AwaitMessageComponentInteractionsOptions
* @property {string[]} [errors] Stop/end reasons that cause the promise to reject
*/

/**
* Similar to createMessageComponentInteractionCollector but in promise form.
* Resolves with a collection of interactions that pass the specified filter.
* Collects a single component interaction that passes the filter.
* The Promise will reject if the time expires.
* @param {CollectorFilter} filter The filter function to use
* @param {AwaitMessageComponentInteractionsOptions} [options={}] Optional options to pass to the internal collector
* @returns {Promise<Collection<string, MessageComponentInteraction>>}
* @param {number} [time] Time to wait for an interaction before rejecting
* @returns {Promise<MessageComponentInteraction>}
* @example
* // Create a message component interaction collector
* // Collect a message component interaction
* const filter = (interaction) => interaction.customID === 'button' && interaction.user.id === 'someID';
* message.awaitMessageComponentInteractions(filter, { time: 15000 })
* .then(collected => console.log(`Collected ${collected.size} interactions`))
* message.awaitMessageComponentInteraction(filter, 15000)
* .then(interaction => console.log(`${interaction.customID} was clicked!`))
* .catch(console.error);
*/
awaitMessageComponentInteractions(filter, options = {}) {
awaitMessageComponentInteraction(filter, time) {
return new Promise((resolve, reject) => {
const collector = this.createMessageComponentInteractionCollector(filter, options);
collector.once('end', (interactions, reason) => {
if (options.errors && options.errors.includes(reason)) reject(interactions);
else resolve(interactions);
const collector = this.createMessageComponentInteractionCollector(filter, { max: 1, time });
collector.once('end', interactions => {
const interaction = interactions.first();
if (!interaction) reject(new Error('INTERACTION_COLLECTOR_TIMEOUT'));
else resolve(interaction);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class TextChannel extends GuildChannel {
createMessageCollector() {}
awaitMessages() {}
createMessageComponentInteractionCollector() {}
awaitMessageComponentInteractions() {}
awaitMessageComponentInteraction() {}
bulkDelete() {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/structures/interfaces/TextBasedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class TextBasedChannel {
'createMessageCollector',
'awaitMessages',
'createMessageComponentInteractionCollector',
'awaitMessageComponentInteractions',
'awaitMessageComponentInteraction',
);
}
for (const prop of props) {
Expand Down