mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 17:21:31 +00:00
fix emoji updates (#826)
This commit is contained in:
parent
422b90c711
commit
b020fae258
3 changed files with 14 additions and 6 deletions
File diff suppressed because one or more lines are too long
|
|
@ -118,6 +118,12 @@ class ClientDataManager {
|
||||||
updateChannel(currentChannel, newData) {
|
updateChannel(currentChannel, newData) {
|
||||||
currentChannel.setup(newData);
|
currentChannel.setup(newData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateEmoji(currentEmoji, newData) {
|
||||||
|
const oldEmoji = cloneObject(currentEmoji);
|
||||||
|
currentEmoji.setup(newData);
|
||||||
|
this.client.emit(Constants.Events.GUILD_EMOJI_UPDATE, oldEmoji, currentEmoji);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientDataManager;
|
module.exports = ClientDataManager;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const Constants = require('../../util/Constants');
|
|
||||||
|
|
||||||
class GuildEmojiUpdateAction extends Action {
|
class GuildEmojiUpdateAction extends Action {
|
||||||
handle(data, guild) {
|
handle(data, guild) {
|
||||||
const client = this.client;
|
const client = this.client;
|
||||||
for (let emoji of data.emojis) {
|
for (let emoji of data.emojis) {
|
||||||
const already = guild.emojis.has(emoji.id);
|
const already = guild.emojis.has(emoji.id);
|
||||||
emoji = client.dataManager.newEmoji(emoji, guild);
|
if (already) {
|
||||||
if (already) client.emit(Constants.Events.GUILD_EMOJI_UPDATE, guild, emoji);
|
client.dataManager.updateEmoji(guild.emojis.get(emoji.id), emoji);
|
||||||
|
} else {
|
||||||
|
emoji = client.dataManager.newEmoji(emoji, guild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (let emoji of guild.emojis) {
|
for (let emoji of guild.emojis) {
|
||||||
if (!data.emoijs.has(emoji.id)) client.dataManager.killEmoji(emoji);
|
if (!data.emoijs.has(emoji.id)) client.dataManager.killEmoji(emoji);
|
||||||
|
|
@ -21,7 +23,7 @@ class GuildEmojiUpdateAction extends Action {
|
||||||
/**
|
/**
|
||||||
* Emitted whenever an emoji is updated
|
* Emitted whenever an emoji is updated
|
||||||
* @event Client#guildEmojiUpdate
|
* @event Client#guildEmojiUpdate
|
||||||
* @param {Guild} guild The guild that the emoji was updated in.
|
* @param {Emoji} oldEmoji The old emoji
|
||||||
* @param {Emoji} emoji The emoji that was updated.
|
* @param {Emoji} newEmoji The new emoji
|
||||||
*/
|
*/
|
||||||
module.exports = GuildEmojiUpdateAction;
|
module.exports = GuildEmojiUpdateAction;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue