mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
Switch to maps for action deleted + more cleaning (#592)
This commit is contained in:
committed by
Amish Shah
parent
a3b9b0f1b4
commit
5af09d335c
@@ -5,7 +5,7 @@ class GuildRoleDeleteAction extends Action {
|
||||
|
||||
constructor(client) {
|
||||
super(client);
|
||||
this.deleted = {};
|
||||
this.deleted = new Map();
|
||||
}
|
||||
|
||||
handle(data) {
|
||||
@@ -16,11 +16,11 @@ class GuildRoleDeleteAction extends Action {
|
||||
let role = guild.roles.get(data.role_id);
|
||||
if (role) {
|
||||
guild.roles.delete(data.role_id);
|
||||
this.deleted[guild.id + data.role_id] = role;
|
||||
this.deleted.set(guild.id + data.role_id, role);
|
||||
this.scheduleForDeletion(guild.id, data.role_id);
|
||||
client.emit(Constants.Events.GUILD_ROLE_DELETE, guild, role);
|
||||
} else {
|
||||
role = this.deleted[guild.id + data.role_id];
|
||||
role = this.deleted.get(guild.id + data.role_id) || null;
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -34,7 +34,7 @@ class GuildRoleDeleteAction extends Action {
|
||||
}
|
||||
|
||||
scheduleForDeletion(guildID, roleID) {
|
||||
this.client.setTimeout(() => delete this.deleted[guildID + roleID], this.client.options.rest_ws_bridge_timeout);
|
||||
this.client.setTimeout(() => this.deleted.delete(guildID + roleID), this.client.options.rest_ws_bridge_timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user