backport: deleted property

This commit is contained in:
Lewdcario
2018-06-29 19:11:50 -05:00
parent 72346fb47e
commit 3fa9ed1f42
13 changed files with 45 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ class ChannelDeleteAction extends Action {
} else {
channel = this.deleted.get(data.id) || null;
}
if (channel) channel.deleted = true;
return { channel };
}

View File

@@ -38,6 +38,7 @@ class GuildDeleteAction extends Action {
} else {
guild = this.deleted.get(data.id) || null;
}
if (guild) guild.deleted = true;
return { guild };
}

View File

@@ -4,6 +4,7 @@ class GuildEmojiDeleteAction extends Action {
handle(emoji) {
const client = this.client;
client.dataManager.killEmoji(emoji);
emoji.deleted = true;
return { emoji };
}
}

View File

@@ -22,6 +22,7 @@ class GuildMemberRemoveAction extends Action {
} else {
member = this.deleted.get(guild.id + data.user.id) || null;
}
if (member) member.deleted = true;
}
return { guild, member };
}

View File

@@ -22,6 +22,7 @@ class GuildRoleDeleteAction extends Action {
} else {
role = this.deleted.get(guild.id + data.role_id) || null;
}
if (role) role.deleted = true;
}
return { role };

View File

@@ -20,6 +20,7 @@ class MessageDeleteAction extends Action {
} else {
message = this.deleted.get(channel.id + data.id) || null;
}
if (message) message.deleted = true;
}
return { message };

View File

@@ -11,6 +11,7 @@ class MessageDeleteBulkAction extends Action {
for (const id of data.ids) {
const message = channel.messages.get(id);
if (message) {
message.deleted = true;
messages.set(message.id, message);
channel.messages.delete(id);
}

View File

@@ -24,6 +24,12 @@ class Channel {
*/
this.type = null;
/**
* Whether the channel has been deleted
* @type {boolean}
*/
this.deleted = false;
if (data) this.setup(data);
}

View File

@@ -22,6 +22,12 @@ class Emoji {
*/
this.guild = guild;
/**
* Whether this emoji has been deleted
* @type {boolean}
*/
this.deleted = false;
this.setup(data);
}

View File

@@ -49,6 +49,12 @@ class Guild {
*/
this.presences = new Collection();
/**
* Whether the bot has been removed from the guild
* @type {boolean}
*/
this.deleted = false;
if (!data) return;
if (data.unavailable) {
/**

View File

@@ -51,6 +51,12 @@ class GuildMember {
* @type {?Message}
*/
this.lastMessage = null;
/**
* Whether the member has been removed from the guild
* @type {boolean}
*/
this.deleted = false;
}
setup(data) {

View File

@@ -29,6 +29,12 @@ class Message {
*/
this.channel = channel;
/**
* Whether this message has been deleted
* @type {boolean}
*/
this.deleted = false;
if (data) this.setup(data);
}
@@ -319,9 +325,9 @@ class Message {
* @readonly
*/
get deletable() {
return this.author.id === this.client.user.id || (this.guild &&
return !this.deleted && (this.author.id === this.client.user.id || (this.guild &&
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES)
);
));
}
/**

View File

@@ -21,6 +21,12 @@ class Role {
*/
this.guild = guild;
/**
* Whether the role has been deleted
* @type {boolean}
*/
this.deleted = false;
if (data) this.setup(data);
}