30
30
from typing_extensions import override
31
31
32
32
from .asset import Asset
33
- from .emoji import GuildEmoji , PartialEmoji , _EmojiTag
33
+ from .emoji import PartialEmoji , _EmojiTag
34
34
from .mixins import Hashable
35
35
from .types .channel import (
36
36
VoiceChannelEffectSendEvent as VoiceChannelEffectSendEventPayload ,
53
53
class PartialSoundboardSound (Hashable ):
54
54
"""A partial soundboard sound.
55
55
56
+ .. versionadded:: 2.7
57
+
56
58
Attributes
57
59
----------
58
60
id: :class:`int`
59
61
The sound's ID.
60
62
volume: :class:`float`
61
63
The sound's volume.
62
- emoji: :class:`PartialEmoji`
63
- The sound's emoji.
64
-
65
- .. versionadded:: 2.7
64
+ emoji: :class:`PartialEmoji` | :class:`None`
65
+ The sound's emoji. Could be ``None`` if the sound has no emoji.
66
66
"""
67
67
68
68
__slots__ = ("id" , "volume" , "emoji" , "_http" , "_state" )
@@ -84,11 +84,14 @@ def _from_data(
84
84
self .volume = (
85
85
float (data .get ("volume" , 0 ) or data .get ("sound_volume" , 0 )) or None
86
86
)
87
+ self .emoji = None
87
88
if raw_emoji := data .get (
88
89
"emoji"
89
90
): # From gateway event (VoiceChannelEffectSendEventPayload)
90
91
self .emoji = PartialEmoji .from_dict (raw_emoji )
91
- else : # From HTTP response (SoundboardSoundPayload)
92
+ elif data .get ("emoji_name" ) or data .get (
93
+ "emoji_id"
94
+ ): # From HTTP response (SoundboardSoundPayload)
92
95
self .emoji = PartialEmoji (
93
96
name = data .get ("emoji_name" ),
94
97
id = int (data .get ("emoji_id" , 0 ) or 0 ) or None ,
@@ -120,25 +123,25 @@ def __repr__(self) -> str:
120
123
class SoundboardSound (PartialSoundboardSound ):
121
124
"""Represents a soundboard sound.
122
125
126
+ .. versionadded:: 2.7
127
+
123
128
Attributes
124
129
----------
125
130
id: :class:`int`
126
131
The sound's ID.
127
132
volume: :class:`float`
128
133
The sound's volume.
134
+ emoji: :class:`PartialEmoji` | :class:`None`
135
+ The sound's emoji. Could be ``None`` if the sound has no emoji.
129
136
name: :class:`str`
130
137
The sound's name.
131
138
available: :class:`bool`
132
139
Whether the sound is available. Could be ``False`` if the sound is not available.
133
140
This happens for example when the guild lost the boost level required to use the sound.
134
- emoji: :class:`PartialEmoji`
135
- The sound's emoji.
136
- guild: :class:`Guild` | :class:`None`
137
- The guild the sound belongs to. Could be ``None`` if the sound is a default sound.
138
- owner: :class:`User`
141
+ guild_id: :class:`int` | :class:`None`
142
+ The ID of the guild the sound belongs to. Could be :class:`None` if the sound is a default sound.
143
+ user: :class:`User` | :class:`None`
139
144
The sound's owner. Could be ``None`` if the sound is a default sound.
140
-
141
- .. versionadded:: 2.7
142
145
"""
143
146
144
147
__slots__ = (
@@ -172,11 +175,7 @@ def _from_data(
172
175
173
176
@cached_slot_property ("_cs_guild" )
174
177
def guild (self ) -> Guild | None :
175
- """:class:`Guild`: The guild the sound belongs to.
176
-
177
- The :class:`Guild` object representing the guild the sound belongs to.
178
- .. versionadded:: 2.7
179
- """
178
+ """:class:`Guild` | :class:`None` The guild the sound belongs to. Could be :class:`None` if the sound is a default sound."""
180
179
return self ._state ._get_guild (self .guild_id ) if self .guild_id else None
181
180
182
181
@override
0 commit comments