Skip to content

Commit f4e32ee

Browse files
committed
♻️ Cleanup
1 parent ae4983d commit f4e32ee

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

discord/channel.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"PartialMessageable",
7878
"ForumChannel",
7979
"ForumTag",
80-
# "VoiceChannelEffect",
8180
"VoiceChannelEffectSendEvent",
8281
)
8382

@@ -3254,6 +3253,11 @@ def get_partial_message(self, message_id: int, /) -> PartialMessage:
32543253

32553254

32563255
class VoiceChannelEffectAnimation(NamedTuple):
3256+
"""Represents an animation that can be sent to a voice channel.
3257+
3258+
.. versionadded:: 2.7
3259+
"""
3260+
32573261
id: int
32583262
type: VoiceChannelEffectAnimationType
32593263

@@ -3264,10 +3268,7 @@ class VoiceChannelSoundEffect(PartialSoundboardSound): ...
32643268
class VoiceChannelEffectSendEvent:
32653269
"""Represents the payload for an :func:`on_voice_channel_effect_send`
32663270
3267-
.. versionadded:: 2.4
3268-
3269-
.. versionchanged:: 2.7
3270-
Added the `sound` attribute.
3271+
.. versionadded:: 2.7
32713272
32723273
Attributes
32733274
----------

discord/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ async def delete_emoji(self, emoji: Snowflake) -> None:
22752275
def get_sound(self, sound_id: int) -> SoundboardSound | None:
22762276
"""Gets a :class:`.Sound` from the bot's sound cache.
22772277
2278-
.. versionadded:: 2.4
2278+
.. versionadded:: 2.7
22792279
22802280
Parameters
22812281
----------

discord/enums.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,10 @@ class PollLayoutType(Enum):
10551055

10561056

10571057
class VoiceChannelEffectAnimationType(Enum):
1058-
"""Voice channel effect animation type"""
1058+
"""Voice channel effect animation type
1059+
1060+
.. versionadded:: 2.7
1061+
"""
10591062

10601063
premium = 0
10611064
basic = 1

discord/guild.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ def categories(self) -> list[CategoryChannel]:
821821
def sounds(self) -> list[SoundboardSound]:
822822
"""A list of soundboard sounds that belong to this guild.
823823
824-
.. versionadded:: 2.5
824+
.. versionadded:: 2.7
825825
826826
This is sorted by the position and are in UI order from top to bottom.
827827
"""
@@ -4316,6 +4316,8 @@ def entitlements(
43164316
def get_sound(self, sound_id: int):
43174317
"""Returns a sound with the given ID.
43184318
4319+
.. versionadded :: 2.7
4320+
43194321
Parameters
43204322
----------
43214323
sound_id: :class:`int`

discord/http.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,7 @@ def get_guild_sound(
32303230
)
32313231

32323232
def edit_guild_sound(
3233-
self, guild_id: Snowflake, sound_Id: Snowflake, *, reason: str | None, **payload
3233+
self, guild_id: Snowflake, sound_id: Snowflake, *, reason: str | None, **payload
32343234
):
32353235
keys = (
32363236
"name",
@@ -3246,14 +3246,14 @@ def edit_guild_sound(
32463246
"PATCH",
32473247
"/guilds/{guild_id}/soundboard-sounds/{sound_id}",
32483248
guild_id=guild_id,
3249-
sound_id=sound_Id,
3249+
sound_id=sound_id,
32503250
),
32513251
json=payload,
32523252
reason=reason,
32533253
)
32543254

32553255
def send_soundboard_sound(
3256-
self, chanel_id: int, sound: PartialSoundboardSound
3256+
self, channel_id: int, sound: PartialSoundboardSound
32573257
) -> None:
32583258
payload = {
32593259
"sound_id": sound.id,
@@ -3265,7 +3265,7 @@ def send_soundboard_sound(
32653265
Route(
32663266
"POST",
32673267
"/channels/{channel_id}/send-soundboard-sound",
3268-
channel_id=chanel_id,
3268+
channel_id=channel_id,
32693269
),
32703270
json=payload,
32713271
)

discord/soundboard.py

+17-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from typing_extensions import override
3131

3232
from .asset import Asset
33-
from .emoji import GuildEmoji, PartialEmoji, _EmojiTag
33+
from .emoji import PartialEmoji, _EmojiTag
3434
from .mixins import Hashable
3535
from .types.channel import (
3636
VoiceChannelEffectSendEvent as VoiceChannelEffectSendEventPayload,
@@ -53,16 +53,16 @@
5353
class PartialSoundboardSound(Hashable):
5454
"""A partial soundboard sound.
5555
56+
.. versionadded:: 2.7
57+
5658
Attributes
5759
----------
5860
id: :class:`int`
5961
The sound's ID.
6062
volume: :class:`float`
6163
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.
6666
"""
6767

6868
__slots__ = ("id", "volume", "emoji", "_http", "_state")
@@ -84,11 +84,14 @@ def _from_data(
8484
self.volume = (
8585
float(data.get("volume", 0) or data.get("sound_volume", 0)) or None
8686
)
87+
self.emoji = None
8788
if raw_emoji := data.get(
8889
"emoji"
8990
): # From gateway event (VoiceChannelEffectSendEventPayload)
9091
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)
9295
self.emoji = PartialEmoji(
9396
name=data.get("emoji_name"),
9497
id=int(data.get("emoji_id", 0) or 0) or None,
@@ -120,25 +123,25 @@ def __repr__(self) -> str:
120123
class SoundboardSound(PartialSoundboardSound):
121124
"""Represents a soundboard sound.
122125
126+
.. versionadded:: 2.7
127+
123128
Attributes
124129
----------
125130
id: :class:`int`
126131
The sound's ID.
127132
volume: :class:`float`
128133
The sound's volume.
134+
emoji: :class:`PartialEmoji` | :class:`None`
135+
The sound's emoji. Could be ``None`` if the sound has no emoji.
129136
name: :class:`str`
130137
The sound's name.
131138
available: :class:`bool`
132139
Whether the sound is available. Could be ``False`` if the sound is not available.
133140
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`
139144
The sound's owner. Could be ``None`` if the sound is a default sound.
140-
141-
.. versionadded:: 2.7
142145
"""
143146

144147
__slots__ = (
@@ -172,11 +175,7 @@ def _from_data(
172175

173176
@cached_slot_property("_cs_guild")
174177
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."""
180179
return self._state._get_guild(self.guild_id) if self.guild_id else None
181180

182181
@override

discord/state.py

-1
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,6 @@ def create_message(
20042004
return Message(state=self, channel=channel, data=data)
20052005

20062006
def parse_voice_channel_effect_send(self, data) -> None:
2007-
__import__("json")
20082007
if sound_id := int(data.get("sound_id", 0)):
20092008
sound = self._get_sound(sound_id)
20102009
if sound is None:

0 commit comments

Comments
 (0)