|
32 | 32 | Callable,
|
33 | 33 | Iterable,
|
34 | 34 | Mapping,
|
| 35 | + NamedTuple, |
35 | 36 | Sequence,
|
36 | 37 | TypeVar,
|
37 | 38 | overload,
|
|
52 | 53 | from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
|
53 | 54 | from .enums import (
|
54 | 55 | VideoQualityMode,
|
| 56 | + VoiceChannelEffectAnimationType, |
55 | 57 | VoiceRegion,
|
56 | 58 | try_enum,
|
57 | 59 | )
|
|
64 | 66 | from .object import Object
|
65 | 67 | from .partial_emoji import PartialEmoji, _EmojiTag
|
66 | 68 | from .permissions import PermissionOverwrite, Permissions
|
| 69 | +from .soundboard import PartialSoundboardSound, SoundboardSound |
67 | 70 | from .stage_instance import StageInstance
|
68 | 71 | from .threads import Thread
|
69 | 72 | from .utils import MISSING
|
|
80 | 83 | "ForumChannel",
|
81 | 84 | "MediaChannel",
|
82 | 85 | "ForumTag",
|
| 86 | + "VoiceChannelEffectSendEvent", |
83 | 87 | )
|
84 | 88 |
|
85 | 89 | if TYPE_CHECKING:
|
|
101 | 105 | from .types.channel import StageChannel as StageChannelPayload
|
102 | 106 | from .types.channel import TextChannel as TextChannelPayload
|
103 | 107 | from .types.channel import VoiceChannel as VoiceChannelPayload
|
| 108 | + from .types.channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend |
104 | 109 | from .types.snowflake import SnowflakeList
|
105 | 110 | from .types.threads import ThreadArchiveDuration
|
106 | 111 | from .ui.view import View
|
@@ -2162,6 +2167,25 @@ async def set_status(self, status: str | None, *, reason: str | None = None) ->
|
2162 | 2167 | """
|
2163 | 2168 | await self._state.http.set_voice_channel_status(self.id, status, reason=reason)
|
2164 | 2169 |
|
| 2170 | + async def send_soundboard_sound(self, sound: PartialSoundboardSound) -> None: |
| 2171 | + """|coro| |
| 2172 | +
|
| 2173 | + Sends a soundboard sound to the voice channel. |
| 2174 | +
|
| 2175 | + Parameters |
| 2176 | + ---------- |
| 2177 | + sound: :class:`PartialSoundboardSound` |
| 2178 | + The soundboard sound to send. |
| 2179 | +
|
| 2180 | + Raises |
| 2181 | + ------ |
| 2182 | + Forbidden |
| 2183 | + You do not have proper permissions to send the soundboard sound. |
| 2184 | + HTTPException |
| 2185 | + Sending the soundboard sound failed. |
| 2186 | + """ |
| 2187 | + await self._state.http.send_soundboard_sound(self.id, sound) |
| 2188 | + |
2165 | 2189 |
|
2166 | 2190 | class StageChannel(discord.abc.Messageable, VocalGuildChannel):
|
2167 | 2191 | """Represents a Discord guild stage channel.
|
@@ -3357,6 +3381,84 @@ def __repr__(self) -> str:
|
3357 | 3381 | return f"<PartialMessageable id={self.id} type={self.type!r}>"
|
3358 | 3382 |
|
3359 | 3383 |
|
| 3384 | +class VoiceChannelEffectAnimation(NamedTuple): |
| 3385 | + """Represents an animation that can be sent to a voice channel. |
| 3386 | +
|
| 3387 | + .. versionadded:: 2.7 |
| 3388 | + """ |
| 3389 | + |
| 3390 | + id: int |
| 3391 | + type: VoiceChannelEffectAnimationType |
| 3392 | + |
| 3393 | + |
| 3394 | +class VoiceChannelSoundEffect(PartialSoundboardSound): ... |
| 3395 | + |
| 3396 | + |
| 3397 | +class VoiceChannelEffectSendEvent: |
| 3398 | + """Represents the payload for an :func:`on_voice_channel_effect_send`. |
| 3399 | +
|
| 3400 | + .. versionadded:: 2.7 |
| 3401 | +
|
| 3402 | + Attributes |
| 3403 | + ---------- |
| 3404 | + animation_type: :class:`int` |
| 3405 | + The type of animation that is being sent. |
| 3406 | + animation_id: :class:`int` |
| 3407 | + The ID of the animation that is being sent. |
| 3408 | + sound: Optional[:class:`SoundboardSound`] |
| 3409 | + The sound that is being sent, could be ``None`` if the effect is not a sound effect. |
| 3410 | + guild: :class:`Guild` |
| 3411 | + The guild in which the sound is being sent. |
| 3412 | + user: :class:`Member` |
| 3413 | + The member that sent the sound. |
| 3414 | + channel: :class:`VoiceChannel` |
| 3415 | + The voice channel in which the sound is being sent. |
| 3416 | + data: :class:`dict` |
| 3417 | + The raw data sent by the gateway. |
| 3418 | + """ |
| 3419 | + |
| 3420 | + __slots__ = ( |
| 3421 | + "_state", |
| 3422 | + "animation_type", |
| 3423 | + "animation_id", |
| 3424 | + "sound", |
| 3425 | + "guild", |
| 3426 | + "user", |
| 3427 | + "channel", |
| 3428 | + "data", |
| 3429 | + "emoji", |
| 3430 | + ) |
| 3431 | + |
| 3432 | + def __init__( |
| 3433 | + self, |
| 3434 | + data: VoiceChannelEffectSend, |
| 3435 | + state: ConnectionState, |
| 3436 | + sound: SoundboardSound | PartialSoundboardSound | None = None, |
| 3437 | + ) -> None: |
| 3438 | + self._state = state |
| 3439 | + channel_id = int(data["channel_id"]) |
| 3440 | + user_id = int(data["user_id"]) |
| 3441 | + guild_id = int(data["guild_id"]) |
| 3442 | + self.animation_type: VoiceChannelEffectAnimationType = try_enum( |
| 3443 | + VoiceChannelEffectAnimationType, data["animation_type"] |
| 3444 | + ) |
| 3445 | + self.animation_id = int(data["animation_id"]) |
| 3446 | + self.sound = sound |
| 3447 | + self.guild = state._get_guild(guild_id) |
| 3448 | + self.user = self.guild.get_member(user_id) |
| 3449 | + self.channel = self.guild.get_channel(channel_id) |
| 3450 | + self.emoji = ( |
| 3451 | + PartialEmoji( |
| 3452 | + name=data["emoji"]["name"], |
| 3453 | + animated=data["emoji"]["animated"], |
| 3454 | + id=data["emoji"]["id"], |
| 3455 | + ) |
| 3456 | + if data.get("emoji", None) |
| 3457 | + else None |
| 3458 | + ) |
| 3459 | + self.data = data |
| 3460 | + |
| 3461 | + |
3360 | 3462 | def _guild_channel_factory(channel_type: int):
|
3361 | 3463 | value = try_enum(ChannelType, channel_type)
|
3362 | 3464 | if value is ChannelType.text:
|
|
0 commit comments