diff --git a/lib/gateway/events.ts b/lib/gateway/events.ts index e91d7522..47e7d5f8 100644 --- a/lib/gateway/events.ts +++ b/lib/gateway/events.ts @@ -404,15 +404,10 @@ export async function GUILD_SOUNDBOARD_SOUND_UPDATE(data: DispatchEventMap["GUIL } export async function GUILD_SOUNDBOARD_SOUNDS_UPDATE(data: DispatchEventMap["GUILD_SOUNDBOARD_SOUNDS_UPDATE"], shard: Shard): Promise { - const guild = shard.client.guilds.get(data[0].guild_id); - if (guild) { - const oldSounds = data.map(rawSound => { - const sound = guild.soundboardSounds.get(rawSound.sound_id); - return sound?.toJSON() ?? null; - }); - shard.client.emit("guildSoundboardSoundsUpdate", data.map(sound => guild.soundboardSounds.update(sound)), oldSounds); - } - shard.client.emit("guildSoundboardSoundsUpdate", data.map(sound => new Soundboard(sound, shard.client)), [null]); + const guild = shard.client.guilds.get(data.guild_id); + const oldSoundboardSounds = data.soundboard_sounds.map(rawSound => guild?.soundboardSounds.get(rawSound.sound_id)?.toJSON() ?? null); + const newSoundboardSounds = data.soundboard_sounds.map(sound => guild?.soundboardSounds.update(sound) ?? new Soundboard(sound, shard.client)); + shard.client.emit("guildSoundboardSoundsUpdate", newSoundboardSounds, oldSoundboardSounds, data.guild_id); } export async function GUILD_STICKERS_UPDATE(data: DispatchEventMap["GUILD_STICKERS_UPDATE"], shard: Shard): Promise { diff --git a/lib/types/events.d.ts b/lib/types/events.d.ts index a60fc537..47bbf061 100644 --- a/lib/types/events.d.ts +++ b/lib/types/events.d.ts @@ -152,7 +152,7 @@ export interface ClientEvents { /** @event Emitted when a guild's soundboard sound is updated. Requires the `GUILD_EXPRESSIONS` intent. */ guildSoundboardSoundUpdate: [soundboardSound: Soundboard, oldSoundboardSound: JSONSoundboard | null]; /** @event Emitted when multiple guild's soundboard sounds are updated. Requires the `GUILD_EXPRESSIONS` intent. */ - guildSoundboardSoundsUpdate: [soundboardSounds: Array, oldSoundboardSounds: Array]; + guildSoundboardSoundsUpdate: [soundboardSounds: Array, oldSoundboardSounds: Array, guildID: string]; /** @event Emitted when a guild's stickers are updated. Requires the `GUILD_EXPRESSIONS` intent. */ guildStickersUpdate: [guild: Guild | Uncached, stickers: Array, oldStickers: Array | null]; /** @event Emitted when a guild becomes unavailable. Requires the `GUILDS` intent. */ diff --git a/lib/types/gateway-raw.d.ts b/lib/types/gateway-raw.d.ts index 4437cabb..e4c4e7fe 100644 --- a/lib/types/gateway-raw.d.ts +++ b/lib/types/gateway-raw.d.ts @@ -365,7 +365,10 @@ export interface GuildSoundboardSoundUpdatePacket extends BaseDispatchPacket { } export interface GuildSoundboardSoundsUpdatePacket extends BaseDispatchPacket { - d: Array; + d: { + guild_id: string; + soundboard_sounds: Array; + }; t: "GUILD_SOUNDBOARD_SOUNDS_UPDATE"; }