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 { } else {
channel = this.deleted.get(data.id) || null; channel = this.deleted.get(data.id) || null;
} }
if (channel) channel.deleted = true;
return { channel }; return { channel };
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,6 +29,12 @@ class Message {
*/ */
this.channel = channel; this.channel = channel;
/**
* Whether this message has been deleted
* @type {boolean}
*/
this.deleted = false;
if (data) this.setup(data); if (data) this.setup(data);
} }
@@ -319,9 +325,9 @@ class Message {
* @readonly * @readonly
*/ */
get deletable() { 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) this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES)
); ));
} }
/** /**

View File

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