mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
fix(GuildEmojiRoleStore): do not prematurely patch roles
Issue is the same as in #2312 and #2381, but for the GuildEmojiRoleStore. Thanks to @KingDGrizzle for pointing this out.
This commit is contained in:
@@ -27,11 +27,9 @@ class GuildEmojiRoleStore extends DataStore {
|
||||
if (roleOrRoles.includes(null)) {
|
||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||
'Array or Collection of Roles or Snowflakes', true));
|
||||
} else {
|
||||
for (const role of roleOrRoles) super.set(role.id, role);
|
||||
}
|
||||
|
||||
return this.set(this);
|
||||
const newRoles = [...new Set(roleOrRoles.concat(this.array()))];
|
||||
return this.set(newRoles);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,11 +46,9 @@ class GuildEmojiRoleStore extends DataStore {
|
||||
if (roleOrRoles.includes(null)) {
|
||||
return Promise.reject(new TypeError('INVALID_TYPE', 'roles',
|
||||
'Array or Collection of Roles or Snowflakes', true));
|
||||
} else {
|
||||
for (const role of roleOrRoles) super.remove(role);
|
||||
}
|
||||
|
||||
return this.set(this);
|
||||
const newRoles = this.keyArray().filter(role => !roleOrRoles.includes(role));
|
||||
return this.set(newRoles);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +70,12 @@ class GuildEmojiRoleStore extends DataStore {
|
||||
return this.emoji.edit({ roles });
|
||||
}
|
||||
|
||||
clone() {
|
||||
const clone = new this.constructor(this.emoji);
|
||||
clone._patch(this.keyArray());
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches the roles for this store
|
||||
* @param {Snowflake[]} roles The new roles
|
||||
|
||||
Reference in New Issue
Block a user