mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
* chore: consistency/prettier * chore: rebase * chore: rebase * chore: include typings * fix: include typings file in prettier lint-staged
38 lines
969 B
JavaScript
38 lines
969 B
JavaScript
'use strict';
|
|
|
|
const Action = require('./Action');
|
|
const DMChannel = require('../../structures/DMChannel');
|
|
const { Events } = require('../../util/Constants');
|
|
|
|
class ChannelDeleteAction extends Action {
|
|
constructor(client) {
|
|
super(client);
|
|
this.deleted = new Map();
|
|
}
|
|
|
|
handle(data) {
|
|
const client = this.client;
|
|
let channel = client.channels.cache.get(data.id);
|
|
|
|
if (channel) {
|
|
client.channels.remove(channel.id);
|
|
channel.deleted = true;
|
|
if (channel.messages && !(channel instanceof DMChannel)) {
|
|
for (const message of channel.messages.cache.values()) {
|
|
message.deleted = true;
|
|
}
|
|
}
|
|
/**
|
|
* Emitted whenever a channel is deleted.
|
|
* @event Client#channelDelete
|
|
* @param {DMChannel|GuildChannel} channel The channel that was deleted
|
|
*/
|
|
client.emit(Events.CHANNEL_DELETE, channel);
|
|
}
|
|
|
|
return { channel };
|
|
}
|
|
}
|
|
|
|
module.exports = ChannelDeleteAction;
|