diff --git a/src/client/ClientDataManager.js b/src/client/ClientDataManager.js index b8a73d67c..1ebcffdef 100644 --- a/src/client/ClientDataManager.js +++ b/src/client/ClientDataManager.js @@ -22,6 +22,14 @@ class ClientDataManager { const already = this.client.guilds.has(data.id); const guild = new Guild(this.client, data); this.client.guilds.set(guild.id, guild); + if (this.client.listenerCount(Constants.Events.GUILD_CACHED)) { + /** + * Emitted whenever a guild is added to the cache + * @event Client#guildCached + * @param {Guild} guild The cached guild + */ + this.client.emit(Constants.Events.GUILD_CACHED, guild); + } if (this.pastReady && !already) { /** * Emitted whenever the client joins a guild. @@ -66,6 +74,15 @@ class ClientDataManager { } if (channel) { + if (this.client.listenerCount(Constants.Events.CHANNEL_CACHED)) { + /** + * Emitted whenever a channel is added to the cache + * @event Client#channelCached + * @param {Channel} channel The cached channel + */ + this.client.emit(Constants.Events.CHANNEL_CACHED, channel); + } + if (this.pastReady && !already) this.client.emit(Constants.Events.CHANNEL_CREATE, channel); this.client.channels.set(channel.id, channel); return channel; diff --git a/src/util/Constants.js b/src/util/Constants.js index 1a9756ad7..a4ce3ed90 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -190,6 +190,7 @@ exports.VoiceOPCodes = { exports.Events = { READY: 'ready', + GUILD_CACHED: 'guildCached', GUILD_CREATE: 'guildCreate', GUILD_DELETE: 'guildDelete', GUILD_UPDATE: 'guildUpdate', @@ -209,6 +210,7 @@ exports.Events = { GUILD_EMOJI_UPDATE: 'guildEmojiUpdate', GUILD_BAN_ADD: 'guildBanAdd', GUILD_BAN_REMOVE: 'guildBanRemove', + CHANNEL_CACHED: 'channelCached', CHANNEL_CREATE: 'channelCreate', CHANNEL_DELETE: 'channelDelete', CHANNEL_UPDATE: 'channelUpdate',