diff --git a/index.d.ts b/index.d.ts index 0760e89c3..7088b360f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -461,7 +461,7 @@ declare namespace Eris { (event: "guildBanAdd" | "guildBanRemove", listener: (guild: Guild, user: User) => void): T; (event: "guildAvailable" | "guildCreate", listener: (guild: Guild) => void): T; (event: "guildDelete", listener: (guild: PossiblyUncachedGuild) => void): T; - (event: "guildEmojisUpdate", listener: (guild: Guild, emojis: Emoji[], oldEmojis: Emoji[]) => void): T; + (event: "guildEmojisUpdate", listener: (guild: PossiblyUncachedGuild, emojis: Emoji[], oldEmojis: Emoji[] | null) => void): T; (event: "guildMemberAdd", listener: (guild: Guild, member: Member) => void): T; (event: "guildMemberChunk", listener: (guild: Guild, members: Member[]) => void): T; (event: "guildMemberRemove", listener: (guild: Guild, member: Member | MemberPartial) => void): T; diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 1f24f1b84..a4be78f38 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -1984,8 +1984,13 @@ class Shard extends EventEmitter { } case "GUILD_EMOJIS_UPDATE": { const guild = this.client.guilds.get(packet.d.guild_id); - const {emojis: oldEmojis} = guild; - guild.update(packet.d); + let oldEmojis = null; + let emojis = packet.d.emojis; + if(guild) { + oldEmojis = guild.emojis; + guild.update(packet.d); + emojis = guild.emojis; + } /** * Fired when a guild's emojis are updated * @event Client#guildEmojisUpdate @@ -1993,7 +1998,7 @@ class Shard extends EventEmitter { * @prop {Array} emojis The updated emojis of the guild * @prop {Array} oldEmojis The old emojis of the guild */ - this.emit("guildEmojisUpdate", guild, guild.emojis, oldEmojis); + this.emit("guildEmojisUpdate", guild || {id: packet.d.guild_id}, emojis, oldEmojis); break; } case "CHANNEL_PINS_UPDATE": {