mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 04:52:22 +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) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
const Action = require('./Action');
|
||||
const Constants = require('../../util/Constants');
|
||||
|
||||
class GuildEmojiUpdateAction extends Action {
|
||||
handle(data, guild) {
|
||||
const client = this.client;
|
||||
for (let emoji of data.emojis) {
|
||||
const already = guild.emojis.has(emoji.id);
|
||||
emoji = client.dataManager.newEmoji(emoji, guild);
|
||||
if (already) client.emit(Constants.Events.GUILD_EMOJI_UPDATE, guild, emoji);
|
||||
if (already) {
|
||||
client.dataManager.updateEmoji(guild.emojis.get(emoji.id), emoji);
|
||||
} else {
|
||||
emoji = client.dataManager.newEmoji(emoji, guild);
|
||||
}
|
||||
}
|
||||
for (let emoji of guild.emojis) {
|
||||
if (!data.emoijs.has(emoji.id)) client.dataManager.killEmoji(emoji);
|
||||
|
|
@ -21,7 +23,7 @@ class GuildEmojiUpdateAction extends Action {
|
|||
/**
|
||||
* Emitted whenever an emoji is updated
|
||||
* @event Client#guildEmojiUpdate
|
||||
* @param {Guild} guild The guild that the emoji was updated in.
|
||||
* @param {Emoji} emoji The emoji that was updated.
|
||||
* @param {Emoji} oldEmoji The old emoji
|
||||
* @param {Emoji} newEmoji The new emoji
|
||||
*/
|
||||
module.exports = GuildEmojiUpdateAction;
|
||||
|
|
|
|||
Loading…
Reference in a new issue