mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
feat(InteractionCollector): reworked to be more generic (#5999)
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -86,6 +86,7 @@ module.exports = {
|
|||||||
Integration: require('./structures/Integration'),
|
Integration: require('./structures/Integration'),
|
||||||
IntegrationApplication: require('./structures/IntegrationApplication'),
|
IntegrationApplication: require('./structures/IntegrationApplication'),
|
||||||
Interaction: require('./structures/Interaction'),
|
Interaction: require('./structures/Interaction'),
|
||||||
|
InteractionCollector: require('./structures/InteractionCollector'),
|
||||||
InteractionWebhook: require('./structures/InteractionWebhook'),
|
InteractionWebhook: require('./structures/InteractionWebhook'),
|
||||||
Invite: require('./structures/Invite'),
|
Invite: require('./structures/Invite'),
|
||||||
Message: require('./structures/Message'),
|
Message: require('./structures/Message'),
|
||||||
@@ -94,7 +95,6 @@ module.exports = {
|
|||||||
MessageButton: require('./structures/MessageButton'),
|
MessageButton: require('./structures/MessageButton'),
|
||||||
MessageCollector: require('./structures/MessageCollector'),
|
MessageCollector: require('./structures/MessageCollector'),
|
||||||
MessageComponentInteraction: require('./structures/MessageComponentInteraction'),
|
MessageComponentInteraction: require('./structures/MessageComponentInteraction'),
|
||||||
MessageComponentInteractionCollector: require('./structures/MessageComponentInteractionCollector'),
|
|
||||||
MessageEmbed: require('./structures/MessageEmbed'),
|
MessageEmbed: require('./structures/MessageEmbed'),
|
||||||
MessageMentions: require('./structures/MessageMentions'),
|
MessageMentions: require('./structures/MessageMentions'),
|
||||||
MessagePayload: require('./structures/MessagePayload'),
|
MessagePayload: require('./structures/MessagePayload'),
|
||||||
|
|||||||
@@ -3,40 +3,69 @@
|
|||||||
const Collector = require('./interfaces/Collector');
|
const Collector = require('./interfaces/Collector');
|
||||||
const Collection = require('../util/Collection');
|
const Collection = require('../util/Collection');
|
||||||
const { Events } = require('../util/Constants');
|
const { Events } = require('../util/Constants');
|
||||||
|
const { InteractionTypes, MessageComponentTypes } = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {CollectorOptions} MessageComponentInteractionCollectorOptions
|
* @typedef {CollectorOptions} InteractionCollectorOptions
|
||||||
* @property {number} max The maximum total amount of interactions to collect
|
* @property {TextChannel|DMChannel|NewsChannel} [channel] The channel to listen to interactions from
|
||||||
* @property {number} maxComponents The maximum number of components to collect
|
* @property {MessageComponentType} [componentType] The type of component to listen for
|
||||||
* @property {number} maxUsers The maximum number of users to interact
|
* @property {Guild} [guild] The guild to listen to interactions from
|
||||||
|
* @property {InteractionType} [interactionType] The type of interaction to listen for
|
||||||
|
* @property {number} [max] The maximum total amount of interactions to collect
|
||||||
|
* @property {number} [maxComponents] The maximum number of components to collect
|
||||||
|
* @property {number} [maxUsers] The maximum number of users to interact
|
||||||
|
* @property {Message} [message] The message to listen to interactions from
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects interaction on message components.
|
* Collects interactions.
|
||||||
* Will automatically stop if the message (`'messageDelete'`),
|
* Will automatically stop if the message (`'messageDelete'`),
|
||||||
* channel (`'channelDelete'`), or guild (`'guildDelete'`) are deleted.
|
* channel (`'channelDelete'`), or guild (`'guildDelete'`) are deleted.
|
||||||
* @extends {Collector}
|
* @extends {Collector}
|
||||||
*/
|
*/
|
||||||
class MessageComponentInteractionCollector extends Collector {
|
class InteractionCollector extends Collector {
|
||||||
/**
|
/**
|
||||||
* @param {Message|TextChannel|DMChannel|NewsChannel} source
|
* @param {Client} client The client on which to collect message component interactions
|
||||||
* The source from which to collect message component interactions
|
* @param {InteractionCollectorOptions} [options={}] The options to apply to this collector
|
||||||
* @param {MessageComponentInteractionCollectorOptions} [options={}] The options to apply to this collector
|
|
||||||
*/
|
*/
|
||||||
constructor(source, options = {}) {
|
constructor(client, options = {}) {
|
||||||
super(source.client, options);
|
super(client, options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message from which to collect message component interactions, if provided
|
* The message from which to collect interactions, if provided
|
||||||
* @type {?Message}
|
* @type {?Message}
|
||||||
*/
|
*/
|
||||||
this.message = source instanceof require('./Message') ? source : null;
|
this.message = options.message ?? null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The source channel from which to collect message component interactions
|
* The channel from which to collect interactions, if provided
|
||||||
* @type {TextChannel|DMChannel|NewsChannel}
|
* @type {?TextChannel|DMChannel|NewsChannel}
|
||||||
*/
|
*/
|
||||||
this.channel = this.message?.channel ?? source;
|
this.channel = this.message?.channel ?? options.channel ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The guild from which to collect interactions, if provided
|
||||||
|
* @type {?Guild}
|
||||||
|
*/
|
||||||
|
this.guild = this.channel?.guild ?? options.guild ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The the type of interaction to collect
|
||||||
|
* @type {?InteractionType}
|
||||||
|
*/
|
||||||
|
this.interactionType =
|
||||||
|
typeof options.interactionType === 'number'
|
||||||
|
? InteractionTypes[options.interactionType]
|
||||||
|
: options.interactionType ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The the type of component to collect
|
||||||
|
* @type {?MessageComponentType}
|
||||||
|
*/
|
||||||
|
this.componentType =
|
||||||
|
typeof options.componentType === 'number'
|
||||||
|
? MessageComponentTypes[options.componentType]
|
||||||
|
: options.componentType ?? null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The users which have interacted to components on this collector
|
* The users which have interacted to components on this collector
|
||||||
@@ -51,23 +80,28 @@ class MessageComponentInteractionCollector extends Collector {
|
|||||||
this.total = 0;
|
this.total = 0;
|
||||||
|
|
||||||
this.empty = this.empty.bind(this);
|
this.empty = this.empty.bind(this);
|
||||||
this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
|
|
||||||
this._handleGuildDeletion = this._handleGuildDeletion.bind(this);
|
|
||||||
this._handleMessageDeletion = this._handleMessageDeletion.bind(this);
|
|
||||||
|
|
||||||
this.client.incrementMaxListeners();
|
this.client.incrementMaxListeners();
|
||||||
|
|
||||||
|
if (this.message) {
|
||||||
|
this._handleMessageDeletion = this._handleMessageDeletion.bind(this);
|
||||||
|
this.client.on(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.channel) {
|
||||||
|
this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
|
||||||
|
this.client.on(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.guild) {
|
||||||
|
this._handleGuildDeletion = this._handleGuildDeletion.bind(this);
|
||||||
|
this.client.on(Events.GUILD_DELETE, this._handleGuildDeletion);
|
||||||
|
}
|
||||||
|
|
||||||
this.client.on(Events.INTERACTION_CREATE, this.handleCollect);
|
this.client.on(Events.INTERACTION_CREATE, this.handleCollect);
|
||||||
|
|
||||||
if (this.message) this.client.on(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
|
||||||
|
|
||||||
this.client.on(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
|
||||||
this.client.on(Events.GUILD_DELETE, this._handleGuildDeletion);
|
|
||||||
|
|
||||||
this.once('end', () => {
|
this.once('end', () => {
|
||||||
this.client.removeListener(Events.INTERACTION_CREATE, this.handleCollect);
|
this.client.removeListener(Events.INTERACTION_CREATE, this.handleCollect);
|
||||||
|
this.client.removeListener(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
||||||
if (this.message) this.client.removeListener(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
|
||||||
|
|
||||||
this.client.removeListener(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
this.client.removeListener(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
||||||
this.client.removeListener(Events.GUILD_DELETE, this._handleGuildDeletion);
|
this.client.removeListener(Events.GUILD_DELETE, this._handleGuildDeletion);
|
||||||
this.client.decrementMaxListeners();
|
this.client.decrementMaxListeners();
|
||||||
@@ -91,13 +125,13 @@ class MessageComponentInteractionCollector extends Collector {
|
|||||||
* @event MessageComponentInteractionCollector#collect
|
* @event MessageComponentInteractionCollector#collect
|
||||||
* @param {Interaction} interaction The interaction that was collected
|
* @param {Interaction} interaction The interaction that was collected
|
||||||
*/
|
*/
|
||||||
if (!interaction.isMessageComponent()) return null;
|
if (this.interactionType && interaction.type !== this.interactionType) return null;
|
||||||
|
if (this.componentType && interaction.componentType !== this.componentType) return null;
|
||||||
|
if (this.message && interaction.message?.id !== this.message.id) return null;
|
||||||
|
if (this.channel && interaction.channelID !== this.channel.id) return null;
|
||||||
|
if (this.guild && interaction.guildID !== this.guild.id) return null;
|
||||||
|
|
||||||
if (this.message) {
|
return interaction.id;
|
||||||
return interaction.message.id === this.message.id ? interaction.id : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return interaction.channel.id === this.channel.id ? interaction.id : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,13 +145,13 @@ class MessageComponentInteractionCollector extends Collector {
|
|||||||
* @event MessageComponentInteractionCollector#dispose
|
* @event MessageComponentInteractionCollector#dispose
|
||||||
* @param {Interaction} interaction The interaction that was disposed of
|
* @param {Interaction} interaction The interaction that was disposed of
|
||||||
*/
|
*/
|
||||||
if (!interaction.isMessageComponent()) return null;
|
if (this.type && interaction.type !== this.type) return null;
|
||||||
|
if (this.componentType && interaction.componentType !== this.componentType) return null;
|
||||||
|
if (this.message && interaction.message?.id !== this.message.id) return null;
|
||||||
|
if (this.channel && interaction.channelID !== this.channel.id) return null;
|
||||||
|
if (this.guild && interaction.guildID !== this.guild.id) return null;
|
||||||
|
|
||||||
if (this.message) {
|
return interaction.id;
|
||||||
return interaction.message.id === this.message.id ? interaction.id : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return interaction.channel.id === this.channel.id ? interaction.id : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +195,7 @@ class MessageComponentInteractionCollector extends Collector {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_handleChannelDeletion(channel) {
|
_handleChannelDeletion(channel) {
|
||||||
if (channel.id === this.channel.id) {
|
if (channel.id === this.channel?.id) {
|
||||||
this.stop('channelDelete');
|
this.stop('channelDelete');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,10 +207,10 @@ class MessageComponentInteractionCollector extends Collector {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_handleGuildDeletion(guild) {
|
_handleGuildDeletion(guild) {
|
||||||
if (guild.id === this.channel.guild?.id) {
|
if (guild.id === this.guild?.id) {
|
||||||
this.stop('guildDelete');
|
this.stop('guildDelete');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MessageComponentInteractionCollector;
|
module.exports = InteractionCollector;
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
const ClientApplication = require('./ClientApplication');
|
const ClientApplication = require('./ClientApplication');
|
||||||
|
const InteractionCollector = require('./InteractionCollector');
|
||||||
const MessageAttachment = require('./MessageAttachment');
|
const MessageAttachment = require('./MessageAttachment');
|
||||||
const MessageComponentInteractionCollector = require('./MessageComponentInteractionCollector');
|
|
||||||
const Embed = require('./MessageEmbed');
|
const Embed = require('./MessageEmbed');
|
||||||
const Mentions = require('./MessageMentions');
|
const Mentions = require('./MessageMentions');
|
||||||
const MessagePayload = require('./MessagePayload');
|
const MessagePayload = require('./MessagePayload');
|
||||||
@@ -439,10 +439,18 @@ class Message extends Base {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {CollectorOptions} MessageComponentCollectorOptions
|
||||||
|
* @property {MessageComponentType} [componentType] The type of component to listen for
|
||||||
|
* @property {number} [max] The maximum total amount of interactions to collect
|
||||||
|
* @property {number} [maxComponents] The maximum number of components to collect
|
||||||
|
* @property {number} [maxUsers] The maximum number of users to interact
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a message component interaction collector.
|
* Creates a message component interaction collector.
|
||||||
* @param {MessageComponentInteractionCollectorOptions} [options={}] Options to send to the collector
|
* @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
|
||||||
* @returns {MessageComponentInteractionCollector}
|
* @returns {InteractionCollector}
|
||||||
* @example
|
* @example
|
||||||
* // Create a message component interaction collector
|
* // Create a message component interaction collector
|
||||||
* const filter = (interaction) => interaction.customID === 'button' && interaction.user.id === 'someID';
|
* const filter = (interaction) => interaction.customID === 'button' && interaction.user.id === 'someID';
|
||||||
@@ -450,21 +458,26 @@ class Message extends Base {
|
|||||||
* collector.on('collect', i => console.log(`Collected ${i.customID}`));
|
* collector.on('collect', i => console.log(`Collected ${i.customID}`));
|
||||||
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
||||||
*/
|
*/
|
||||||
createMessageComponentInteractionCollector(options = {}) {
|
createMessageComponentCollector(options = {}) {
|
||||||
return new MessageComponentInteractionCollector(this, options);
|
return new InteractionCollector(this.client, {
|
||||||
|
...options,
|
||||||
|
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
||||||
|
message: this,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object containing the same properties as CollectorOptions, but a few more:
|
* An object containing the same properties as CollectorOptions, but a few more:
|
||||||
* @typedef {Object} AwaitMessageComponentInteractionOptions
|
* @typedef {Object} AwaitMessageComponentOptions
|
||||||
* @property {CollectorFilter} [filter] The filter applied to this collector
|
* @property {CollectorFilter} [filter] The filter applied to this collector
|
||||||
* @property {number} [time] Time to wait for an interaction before rejecting
|
* @property {number} [time] Time to wait for an interaction before rejecting
|
||||||
|
* @property {MessageComponentType} [componentType] The type of component interaction to collect
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects a single component interaction that passes the filter.
|
* Collects a single component interaction that passes the filter.
|
||||||
* The Promise will reject if the time expires.
|
* The Promise will reject if the time expires.
|
||||||
* @param {AwaitMessageComponentInteractionOptions} [options={}] Options to pass to the internal collector
|
* @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
|
||||||
* @returns {Promise<MessageComponentInteraction>}
|
* @returns {Promise<MessageComponentInteraction>}
|
||||||
* @example
|
* @example
|
||||||
* // Collect a message component interaction
|
* // Collect a message component interaction
|
||||||
@@ -473,9 +486,10 @@ class Message extends Base {
|
|||||||
* .then(interaction => console.log(`${interaction.customID} was clicked!`))
|
* .then(interaction => console.log(`${interaction.customID} was clicked!`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
awaitMessageComponentInteraction(options = {}) {
|
awaitMessageComponent(options = {}) {
|
||||||
|
const _options = { ...options, max: 1 };
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const collector = this.createMessageComponentInteractionCollector({ ...options, max: 1 });
|
const collector = this.createMessageComponentCollector(_options);
|
||||||
collector.once('end', (interactions, reason) => {
|
collector.once('end', (interactions, reason) => {
|
||||||
const interaction = interactions.first();
|
const interaction = interactions.first();
|
||||||
if (interaction) resolve(interaction);
|
if (interaction) resolve(interaction);
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ const MessageCollector = require('../MessageCollector');
|
|||||||
const MessagePayload = require('../MessagePayload');
|
const MessagePayload = require('../MessagePayload');
|
||||||
const SnowflakeUtil = require('../../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../../util/SnowflakeUtil');
|
||||||
const Collection = require('../../util/Collection');
|
const Collection = require('../../util/Collection');
|
||||||
|
const { InteractionTypes } = require('../../util/Constants');
|
||||||
const { RangeError, TypeError, Error } = require('../../errors');
|
const { RangeError, TypeError, Error } = require('../../errors');
|
||||||
const MessageComponentInteractionCollector = require('../MessageComponentInteractionCollector');
|
const InteractionCollector = require('../InteractionCollector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for classes that have text-channel-like features.
|
* Interface for classes that have text-channel-like features.
|
||||||
@@ -304,8 +305,8 @@ class TextBasedChannel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a button interaction collector.
|
* Creates a button interaction collector.
|
||||||
* @param {MessageComponentInteractionCollectorOptions} [options={}] Options to send to the collector
|
* @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
|
||||||
* @returns {MessageComponentInteractionCollector}
|
* @returns {InteractionCollector}
|
||||||
* @example
|
* @example
|
||||||
* // Create a button interaction collector
|
* // Create a button interaction collector
|
||||||
* const filter = (interaction) => interaction.customID === 'button' && interaction.user.id === 'someID';
|
* const filter = (interaction) => interaction.customID === 'button' && interaction.user.id === 'someID';
|
||||||
@@ -313,14 +314,18 @@ class TextBasedChannel {
|
|||||||
* collector.on('collect', i => console.log(`Collected ${i.customID}`));
|
* collector.on('collect', i => console.log(`Collected ${i.customID}`));
|
||||||
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
* collector.on('end', collected => console.log(`Collected ${collected.size} items`));
|
||||||
*/
|
*/
|
||||||
createMessageComponentInteractionCollector(options = {}) {
|
createMessageComponentCollector(options = {}) {
|
||||||
return new MessageComponentInteractionCollector(this, options);
|
return new InteractionCollector(this.client, {
|
||||||
|
...options,
|
||||||
|
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
||||||
|
channel: this,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects a single component interaction that passes the filter.
|
* Collects a single component interaction that passes the filter.
|
||||||
* The Promise will reject if the time expires.
|
* The Promise will reject if the time expires.
|
||||||
* @param {AwaitMessageComponentInteractionOptions} [options={}] Options to pass to the internal collector
|
* @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
|
||||||
* @returns {Promise<MessageComponentInteraction>}
|
* @returns {Promise<MessageComponentInteraction>}
|
||||||
* @example
|
* @example
|
||||||
* // Collect a message component interaction
|
* // Collect a message component interaction
|
||||||
@@ -329,9 +334,10 @@ class TextBasedChannel {
|
|||||||
* .then(interaction => console.log(`${interaction.customID} was clicked!`))
|
* .then(interaction => console.log(`${interaction.customID} was clicked!`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
awaitMessageComponentInteraction(options = {}) {
|
awaitMessageComponent(options = {}) {
|
||||||
|
const _options = { ...options, max: 1 };
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const collector = this.createMessageComponentInteractionCollector({ ...options, max: 1 });
|
const collector = this.createMessageComponentCollector(_options);
|
||||||
collector.once('end', (interactions, reason) => {
|
collector.once('end', (interactions, reason) => {
|
||||||
const interaction = interactions.first();
|
const interaction = interactions.first();
|
||||||
if (interaction) resolve(interaction);
|
if (interaction) resolve(interaction);
|
||||||
@@ -404,8 +410,8 @@ class TextBasedChannel {
|
|||||||
'typingCount',
|
'typingCount',
|
||||||
'createMessageCollector',
|
'createMessageCollector',
|
||||||
'awaitMessages',
|
'awaitMessages',
|
||||||
'createMessageComponentInteractionCollector',
|
'createMessageComponentCollector',
|
||||||
'awaitMessageComponentInteraction',
|
'awaitMessageComponent',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
|
|||||||
116
typings/index.d.ts
vendored
116
typings/index.d.ts
vendored
@@ -1224,6 +1224,34 @@ declare module 'discord.js' {
|
|||||||
public isSelectMenu(): this is SelectMenuInteraction;
|
public isSelectMenu(): this is SelectMenuInteraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class InteractionCollector<T extends Interaction> extends Collector<Snowflake, T> {
|
||||||
|
constructor(client: Client, options?: InteractionCollectorOptions<T>);
|
||||||
|
private _handleMessageDeletion(message: Message): void;
|
||||||
|
private _handleChannelDeletion(channel: GuildChannel): void;
|
||||||
|
private _handleGuildDeletion(guild: Guild): void;
|
||||||
|
|
||||||
|
public channel: TextChannel | NewsChannel | DMChannel | null;
|
||||||
|
public componentType: MessageComponentType | null;
|
||||||
|
public readonly endReason: string | null;
|
||||||
|
public guild: Guild | null;
|
||||||
|
public interactionType: InteractionType | null;
|
||||||
|
public message: Message | null;
|
||||||
|
public options: InteractionCollectorOptions<T>;
|
||||||
|
public total: number;
|
||||||
|
public users: Collection<Snowflake, User>;
|
||||||
|
|
||||||
|
public collect(interaction: Interaction): Snowflake;
|
||||||
|
public empty(): void;
|
||||||
|
public dispose(interaction: Interaction): Snowflake;
|
||||||
|
public on(event: 'collect' | 'dispose', listener: (interaction: T) => Awaited<void>): this;
|
||||||
|
public on(event: 'end', listener: (collected: Collection<Snowflake, T>, reason: string) => Awaited<void>): this;
|
||||||
|
public on(event: string, listener: (...args: any[]) => Awaited<void>): this;
|
||||||
|
|
||||||
|
public once(event: 'collect' | 'dispose', listener: (interaction: T) => Awaited<void>): this;
|
||||||
|
public once(event: 'end', listener: (collected: Collection<Snowflake, T>, reason: string) => Awaited<void>): this;
|
||||||
|
public once(event: string, listener: (...args: any[]) => Awaited<void>): this;
|
||||||
|
}
|
||||||
|
|
||||||
export class InteractionWebhook extends PartialWebhookMixin() {
|
export class InteractionWebhook extends PartialWebhookMixin() {
|
||||||
constructor(client: Client, id: Snowflake, token: string);
|
constructor(client: Client, id: Snowflake, token: string);
|
||||||
public token: string;
|
public token: string;
|
||||||
@@ -1316,14 +1344,14 @@ declare module 'discord.js' {
|
|||||||
public webhookID: Snowflake | null;
|
public webhookID: Snowflake | null;
|
||||||
public flags: Readonly<MessageFlags>;
|
public flags: Readonly<MessageFlags>;
|
||||||
public reference: MessageReference | null;
|
public reference: MessageReference | null;
|
||||||
public awaitMessageComponentInteraction(
|
public awaitMessageComponent<T extends MessageComponentInteraction = MessageComponentInteraction>(
|
||||||
options?: AwaitMessageComponentInteractionOptions,
|
options?: AwaitMessageComponentOptions<T>,
|
||||||
): Promise<MessageComponentInteraction>;
|
): Promise<T>;
|
||||||
public awaitReactions(options?: AwaitReactionsOptions): Promise<Collection<Snowflake | string, MessageReaction>>;
|
public awaitReactions(options?: AwaitReactionsOptions): Promise<Collection<Snowflake | string, MessageReaction>>;
|
||||||
public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
|
public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
|
||||||
public createMessageComponentInteractionCollector(
|
public createMessageComponentCollector<T extends MessageComponentInteraction = MessageComponentInteraction>(
|
||||||
options?: MessageComponentInteractionCollectorOptions,
|
options?: InteractionCollectorOptions<T>,
|
||||||
): MessageComponentInteractionCollector;
|
): InteractionCollector<T>;
|
||||||
public delete(): Promise<Message>;
|
public delete(): Promise<Message>;
|
||||||
public edit(content: string | MessageEditOptions | MessagePayload): Promise<Message>;
|
public edit(content: string | MessageEditOptions | MessagePayload): Promise<Message>;
|
||||||
public equals(message: Message, rawData: unknown): boolean;
|
public equals(message: Message, rawData: unknown): boolean;
|
||||||
@@ -1438,46 +1466,6 @@ declare module 'discord.js' {
|
|||||||
public static resolveType(type: MessageComponentTypeResolvable): MessageComponentType;
|
public static resolveType(type: MessageComponentTypeResolvable): MessageComponentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MessageComponentInteractionCollector extends Collector<Snowflake, MessageComponentInteraction> {
|
|
||||||
constructor(
|
|
||||||
source: Message | TextChannel | DMChannel | ThreadChannel,
|
|
||||||
options?: MessageComponentInteractionCollectorOptions,
|
|
||||||
);
|
|
||||||
private _handleMessageDeletion(message: Message): void;
|
|
||||||
private _handleChannelDeletion(channel: GuildChannel): void;
|
|
||||||
private _handleGuildDeletion(guild: Guild): void;
|
|
||||||
|
|
||||||
public channel: TextChannel | DMChannel | ThreadChannel;
|
|
||||||
public empty(): void;
|
|
||||||
public readonly endReason: string | null;
|
|
||||||
public message: Message | null;
|
|
||||||
public options: MessageComponentInteractionCollectorOptions;
|
|
||||||
public total: number;
|
|
||||||
public users: Collection<Snowflake, User>;
|
|
||||||
|
|
||||||
public collect(interaction: Interaction): Snowflake | null;
|
|
||||||
public dispose(interaction: Interaction): Snowflake | null;
|
|
||||||
public on(
|
|
||||||
event: 'collect' | 'dispose',
|
|
||||||
listener: (interaction: MessageComponentInteraction) => Awaited<void>,
|
|
||||||
): this;
|
|
||||||
public on(
|
|
||||||
event: 'end',
|
|
||||||
listener: (collected: Collection<Snowflake, MessageComponentInteraction>, reason: string) => Awaited<void>,
|
|
||||||
): this;
|
|
||||||
public on(event: string, listener: (...args: any[]) => Awaited<void>): this;
|
|
||||||
|
|
||||||
public once(
|
|
||||||
event: 'collect' | 'dispose',
|
|
||||||
listener: (interaction: MessageComponentInteraction) => Awaited<void>,
|
|
||||||
): this;
|
|
||||||
public once(
|
|
||||||
event: 'end',
|
|
||||||
listener: (collected: Collection<Snowflake, MessageComponentInteraction>, reason: string) => Awaited<void>,
|
|
||||||
): this;
|
|
||||||
public once(event: string, listener: (...args: any[]) => Awaited<void>): this;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MessageEmbed {
|
export class MessageEmbed {
|
||||||
constructor(data?: MessageEmbed | MessageEmbedOptions);
|
constructor(data?: MessageEmbed | MessageEmbedOptions);
|
||||||
public author: MessageEmbedAuthor | null;
|
public author: MessageEmbedAuthor | null;
|
||||||
@@ -2734,17 +2722,17 @@ declare module 'discord.js' {
|
|||||||
readonly lastPinAt: Date | null;
|
readonly lastPinAt: Date | null;
|
||||||
typing: boolean;
|
typing: boolean;
|
||||||
typingCount: number;
|
typingCount: number;
|
||||||
awaitMessageComponentInteraction(
|
awaitMessageComponent<T extends MessageComponentInteraction = MessageComponentInteraction>(
|
||||||
options?: AwaitMessageComponentInteractionOptions,
|
options?: AwaitMessageComponentOptions<T>,
|
||||||
): Promise<MessageComponentInteraction>;
|
): Promise<T>;
|
||||||
awaitMessages(options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
awaitMessages(options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
||||||
bulkDelete(
|
bulkDelete(
|
||||||
messages: Collection<Snowflake, Message> | readonly MessageResolvable[] | number,
|
messages: Collection<Snowflake, Message> | readonly MessageResolvable[] | number,
|
||||||
filterOld?: boolean,
|
filterOld?: boolean,
|
||||||
): Promise<Collection<Snowflake, Message>>;
|
): Promise<Collection<Snowflake, Message>>;
|
||||||
createMessageComponentInteractionCollector(
|
createMessageComponentCollector<T extends MessageComponentInteraction = MessageComponentInteraction>(
|
||||||
options?: MessageComponentInteractionCollectorOptions,
|
options?: InteractionCollectorOptions<T>,
|
||||||
): MessageComponentInteractionCollector;
|
): InteractionCollector<T>;
|
||||||
createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
|
createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
|
||||||
startTyping(count?: number): Promise<void>;
|
startTyping(count?: number): Promise<void>;
|
||||||
stopTyping(force?: boolean): void;
|
stopTyping(force?: boolean): void;
|
||||||
@@ -2987,10 +2975,8 @@ declare module 'discord.js' {
|
|||||||
new?: any;
|
new?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AwaitMessageComponentInteractionOptions {
|
interface AwaitMessageComponentOptions<T extends MessageComponentInteraction>
|
||||||
filter?: CollectorFilter<[MessageComponentInteraction]>;
|
extends Omit<MessageComponentCollectorOptions<T>, 'max' | 'maxComponents' | 'maxUsers'> {}
|
||||||
time?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AwaitMessagesOptions extends MessageCollectorOptions {
|
interface AwaitMessagesOptions extends MessageCollectorOptions {
|
||||||
errors?: string[];
|
errors?: string[];
|
||||||
@@ -3674,6 +3660,17 @@ declare module 'discord.js' {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface InteractionCollectorOptions<T extends Interaction> extends CollectorOptions<[T]> {
|
||||||
|
channel?: TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
||||||
|
componentType?: MessageComponentType | MessageComponentTypes;
|
||||||
|
guild?: Guild;
|
||||||
|
interactionType?: InteractionType | InteractionTypes;
|
||||||
|
max?: number;
|
||||||
|
maxComponents?: number;
|
||||||
|
maxUsers?: number;
|
||||||
|
message?: Message;
|
||||||
|
}
|
||||||
|
|
||||||
interface InteractionDeferOptions {
|
interface InteractionDeferOptions {
|
||||||
ephemeral?: boolean;
|
ephemeral?: boolean;
|
||||||
fetchReply?: boolean;
|
fetchReply?: boolean;
|
||||||
@@ -3789,11 +3786,8 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type MessageComponent = BaseMessageComponent | MessageActionRow | MessageButton | MessageSelectMenu;
|
type MessageComponent = BaseMessageComponent | MessageActionRow | MessageButton | MessageSelectMenu;
|
||||||
|
|
||||||
interface MessageComponentInteractionCollectorOptions extends CollectorOptions<[MessageComponentInteraction]> {
|
interface MessageComponentCollectorOptions<T extends MessageComponentInteraction>
|
||||||
max?: number;
|
extends Omit<InteractionCollectorOptions<T>, 'channel' | 'message' | 'guild' | 'interactionType'> {}
|
||||||
maxComponents?: number;
|
|
||||||
maxUsers?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type MessageComponentOptions =
|
type MessageComponentOptions =
|
||||||
| BaseMessageComponentOptions
|
| BaseMessageComponentOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user