8787 from .types .guild import Guild as GuildPayload
8888 from .types .message import Message as MessagePayload
8989 from .types .poll import Poll as PollPayload
90+ from .types .soundboard import SounboardSound as SoundboardSoundPayload
9091 from .types .sticker import GuildSticker as GuildStickerPayload
9192 from .types .user import User as UserPayload
9293 from .voice_client import VoiceClient
@@ -2017,6 +2018,11 @@ def parse_voice_channel_effect_send(self, data) -> None:
20172018 def _get_sound (self , sound_id : int ) -> SoundboardSound | None :
20182019 return self ._sounds .get (sound_id )
20192020
2021+ def _update_sound (self , sound : SoundboardSound ) -> SoundboardSound | None :
2022+ before = self ._sounds .get (sound .id )
2023+ self ._sounds [sound .id ] = sound
2024+ return before
2025+
20202026 def parse_soundboard_sounds (self , data ) -> None :
20212027 guild_id = int (data ["guild_id" ])
20222028 for sound_data in data ["soundboard_sounds" ]:
@@ -2026,6 +2032,36 @@ def parse_soundboard_sounds(self, data) -> None:
20262032 )
20272033 )
20282034
2035+ def parse_guild_soundboard_sounds_update (self , data ):
2036+ before_sounds = []
2037+ after_sounds = []
2038+ for sound_data in data ["soundboard_sounds" ]:
2039+ after = SoundboardSound (state = self , http = self .http , data = sound_data )
2040+ if before := self ._update_sound (after ):
2041+ before_sounds .append (before )
2042+ after_sounds .append (after )
2043+ if len (before_sounds ) == len (after_sounds ):
2044+ self .dispatch ("soundboard_sounds_update" , before_sounds , after_sounds )
2045+ self .dispatch ("raw_soundboard_sounds_update" , after_sounds )
2046+
2047+ def parse_guild_soundboard_sound_update (self , data ):
2048+ after = SoundboardSound (state = self , http = self .http , data = data )
2049+ if before := self ._update_sound (after ):
2050+ self .dispatch ("soundboard_sound_update" , before , after )
2051+ self .dispatch ("raw_soundboard_sound_update" , after )
2052+
2053+ def parse_guild_soundboard_sound_create (self , data ):
2054+ sound = SoundboardSound (state = self , http = self .http , data = data )
2055+ self ._add_sound (sound )
2056+ self .dispatch ("soundboard_sound_create" , sound )
2057+
2058+ def parse_guild_soundboard_sound_delete (self , data ):
2059+ sound_id = int (data ["sound_id" ])
2060+ sound = self ._get_sound (sound_id )
2061+ if sound is not None :
2062+ self ._remove_sound (sound )
2063+ self .dispatch ("soundboard_sound_delete" , sound )
2064+
20292065 async def _add_default_sounds (self ):
20302066 default_sounds = await self .http .get_default_sounds ()
20312067 for default_sound in default_sounds :
0 commit comments