mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
Add full guild emoji functionality (#749)
* all the emoji stuff
* fix things for hydra 😘
* feck i need to stop committing on github
* update docs again
* Butts
This commit is contained in:
committed by
Schuyler Cebulskie
parent
682e33cad9
commit
aed75e1f9a
@@ -20,6 +20,9 @@ class ActionsManager {
|
||||
this.register('UserGet');
|
||||
this.register('UserUpdate');
|
||||
this.register('GuildSync');
|
||||
this.register('GuildEmojiCreate');
|
||||
this.register('GuildEmojiDelete');
|
||||
this.register('GuildEmojiUpdate');
|
||||
}
|
||||
|
||||
register(name) {
|
||||
|
||||
18
src/client/actions/GuildEmojiCreate.js
Normal file
18
src/client/actions/GuildEmojiCreate.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class EmojiCreateAction extends Action {
|
||||
handle(data, guild) {
|
||||
const client = this.client;
|
||||
const emoji = client.dataManager.newEmoji(data, guild);
|
||||
return {
|
||||
emoji,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever an emoji is created
|
||||
* @event Client#guildEmojiCreate
|
||||
* @param {Emoji} emoji The emoji that was created.
|
||||
*/
|
||||
module.exports = EmojiCreateAction;
|
||||
18
src/client/actions/GuildEmojiDelete.js
Normal file
18
src/client/actions/GuildEmojiDelete.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class EmojiDeleteAction extends Action {
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
client.dataManager.killEmoji(data);
|
||||
return {
|
||||
data,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever an emoji is deleted
|
||||
* @event Client#guildEmojiDelete
|
||||
* @param {Emoji} emoji The emoji that was deleted.
|
||||
*/
|
||||
module.exports = EmojiDeleteAction;
|
||||
27
src/client/actions/GuildEmojiUpdate.js
Normal file
27
src/client/actions/GuildEmojiUpdate.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
for (let emoji of guild.emojis) {
|
||||
if (!data.emoijs.has(emoji.id)) client.dataManager.killEmoji(emoji);
|
||||
}
|
||||
return {
|
||||
emojis: data.emojis,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
module.exports = GuildEmojiUpdateAction;
|
||||
Reference in New Issue
Block a user