diff --git a/src/structures/GuildEmoji.js b/src/structures/GuildEmoji.js index 4811f207e..e9fde762a 100644 --- a/src/structures/GuildEmoji.js +++ b/src/structures/GuildEmoji.js @@ -23,21 +23,21 @@ class GuildEmoji extends Emoji { } _patch(data) { - this.name = data.name; + if (data.name) this.name = data.name; /** * Whether or not this emoji requires colons surrounding it * @type {boolean} */ - this.requiresColons = data.require_colons; + if (typeof data.require_colons !== 'undefined') this.requiresColons = data.require_colons; /** * Whether this emoji is managed by an external service * @type {boolean} */ - this.managed = data.managed; + if (typeof data.managed !== 'undefined') this.managed = data.managed; - if (data.roles) this.roles._patch(data.roles); + if (data.roles) this._roles = data.roles; } _clone() { @@ -114,14 +114,15 @@ class GuildEmoji extends Emoji { * .catch(console.error); */ edit(data, reason) { + const roles = data.roles ? data.roles.map(r => r.id || r) : undefined; return this.client.api.guilds(this.guild.id).emojis(this.id) .patch({ data: { name: data.name, - roles: data.roles ? data.roles.map(r => r.id ? r.id : r) : undefined, + roles, }, reason }) - .then(() => { + .then(newData => { const clone = this._clone(); - clone._patch(data); + clone._patch(newData); return clone; }); }