fix(ChannelDelete): mark messages of a deleted channel as deleted (#3572)

This commit is contained in:
SpaceEEC
2020-01-05 18:29:14 +01:00
committed by GitHub
parent 367c80070f
commit d1d0d75d4a

View File

@@ -1,4 +1,5 @@
const Action = require('./Action');
const DMChannel = require('../../structures/DMChannel');
class ChannelDeleteAction extends Action {
constructor(client) {
@@ -17,7 +18,14 @@ class ChannelDeleteAction extends Action {
} else {
channel = this.deleted.get(data.id) || null;
}
if (channel) channel.deleted = true;
if (channel) {
if (channel.messages && !(channel instanceof DMChannel)) {
for (const message of channel.messages.values()) {
message.deleted = true;
}
}
channel.deleted = true;
}
return { channel };
}