mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Add functionality for GuildEmoji events
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class EmojiCreateAction extends Action {
|
||||
handle(data, guild) {
|
||||
class GuildEmojiCreateAction extends Action {
|
||||
handle(guild, createdEmoji) {
|
||||
const client = this.client;
|
||||
const emoji = client.dataManager.newEmoji(data, guild);
|
||||
const emoji = client.dataManager.newEmoji(createdEmoji, guild);
|
||||
return {
|
||||
emoji,
|
||||
};
|
||||
@@ -15,4 +15,4 @@ class EmojiCreateAction extends Action {
|
||||
* @event Client#guildEmojiCreate
|
||||
* @param {Emoji} emoji The emoji that was created.
|
||||
*/
|
||||
module.exports = EmojiCreateAction;
|
||||
module.exports = GuildEmojiCreateAction;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class EmojiDeleteAction extends Action {
|
||||
handle(data) {
|
||||
class GuildEmojiDeleteAction extends Action {
|
||||
handle(emoji) {
|
||||
const client = this.client;
|
||||
client.dataManager.killEmoji(data);
|
||||
client.dataManager.killEmoji(emoji);
|
||||
return {
|
||||
data,
|
||||
emoji,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,4 @@ class EmojiDeleteAction extends Action {
|
||||
* @event Client#guildEmojiDelete
|
||||
* @param {Emoji} emoji The emoji that was deleted.
|
||||
*/
|
||||
module.exports = EmojiDeleteAction;
|
||||
module.exports = GuildEmojiDeleteAction;
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class GuildEmojiUpdateAction extends Action {
|
||||
handle(data, guild) {
|
||||
const client = this.client;
|
||||
for (let emoji of data.emojis) {
|
||||
const already = guild.emojis.has(emoji.id);
|
||||
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);
|
||||
}
|
||||
return {
|
||||
emojis: data.emojis,
|
||||
};
|
||||
handle(oldEmoji, newEmoji) {
|
||||
this.client.dataManager.updateEmoji(oldEmoji, newEmoji);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user