mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Attempt to fix cache crash
This commit is contained in:
@@ -115,20 +115,18 @@ var Cache = (function (_Array) {
|
||||
};
|
||||
|
||||
Cache.prototype.update = function update(old, data) {
|
||||
var item = this.get(this[discrimS], old[this[discrimS]]);
|
||||
|
||||
if (item) {
|
||||
var index = this.indexOf(item);
|
||||
for (var dataIndex in data) {
|
||||
if (data.hasOwnProperty(dataIndex)) {
|
||||
this[index][dataIndex] = data[dataIndex];
|
||||
for (var i in this) {
|
||||
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
for (var key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
this[i][key] = data[key];
|
||||
}
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[i];
|
||||
return this[i];
|
||||
}
|
||||
this[discrimCacheS][data[this[discrimS]]] = this[index];
|
||||
return this[index];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Cache.prototype.random = function random() {
|
||||
@@ -137,13 +135,10 @@ var Cache = (function (_Array) {
|
||||
|
||||
Cache.prototype.remove = function remove(data) {
|
||||
delete this[discrimCacheS][data[this[discrimS]]];
|
||||
var index = this.indexOf(data);
|
||||
if (~index) {
|
||||
this.splice(index, 1);
|
||||
} else {
|
||||
var item = this.get(this[discrimS], data[this[discrimS]]);
|
||||
if (item) {
|
||||
this.splice(this.indexOf(item), 1);
|
||||
for (var i in this) {
|
||||
if (this[i][this[discrimS]] === old[this[discrimS]]) {
|
||||
this.splice(i, 1);
|
||||
return this[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user