mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(InteractionCollector): handle thread (and parent) deletion (#7070)
This commit is contained in:
@@ -105,7 +105,9 @@ class InteractionCollector extends Collector {
|
|||||||
|
|
||||||
if (this.channelId) {
|
if (this.channelId) {
|
||||||
this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
|
this._handleChannelDeletion = this._handleChannelDeletion.bind(this);
|
||||||
|
this._handleThreadDeletion = this._handleThreadDeletion.bind(this);
|
||||||
this.client.on(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
this.client.on(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
||||||
|
this.client.on(Events.THREAD_DELETE, this._handleThreadDeletion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.guildId) {
|
if (this.guildId) {
|
||||||
@@ -120,6 +122,7 @@ class InteractionCollector extends Collector {
|
|||||||
this.client.removeListener(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
this.client.removeListener(Events.MESSAGE_DELETE, this._handleMessageDeletion);
|
||||||
this.client.removeListener(Events.MESSAGE_BULK_DELETE, bulkDeleteListener);
|
this.client.removeListener(Events.MESSAGE_BULK_DELETE, bulkDeleteListener);
|
||||||
this.client.removeListener(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
this.client.removeListener(Events.CHANNEL_DELETE, this._handleChannelDeletion);
|
||||||
|
this.client.removeListener(Events.THREAD_DELETE, this._handleThreadDeletion);
|
||||||
this.client.removeListener(Events.GUILD_DELETE, this._handleGuildDeletion);
|
this.client.removeListener(Events.GUILD_DELETE, this._handleGuildDeletion);
|
||||||
this.client.decrementMaxListeners();
|
this.client.decrementMaxListeners();
|
||||||
});
|
});
|
||||||
@@ -212,11 +215,23 @@ class InteractionCollector extends Collector {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_handleChannelDeletion(channel) {
|
_handleChannelDeletion(channel) {
|
||||||
if (channel.id === this.channelId) {
|
if (channel.id === this.channelId || channel.threads?.cache.has(this.channelId)) {
|
||||||
this.stop('channelDelete');
|
this.stop('channelDelete');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles checking if the thread has been deleted, and if so, stops the collector with the reason 'threadDelete'.
|
||||||
|
* @private
|
||||||
|
* @param {ThreadChannel} thread The thread that was deleted
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
_handleThreadDeletion(thread) {
|
||||||
|
if (thread.id === this.channelId) {
|
||||||
|
this.stop('threadDelete');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
|
* Handles checking if the guild has been deleted, and if so, stops the collector with the reason 'guildDelete'.
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Reference in New Issue
Block a user