|
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
|
|
79 | 82 | "ForumChannel",
|
80 | 83 | "MediaChannel",
|
81 | 84 | "ForumTag",
|
| 85 | + "VoiceChannelEffectSendEvent", |
82 | 86 | )
|
83 | 87 |
|
84 | 88 | if TYPE_CHECKING:
|
|
100 | 104 | from .types.channel import StageChannel as StageChannelPayload
|
101 | 105 | from .types.channel import TextChannel as TextChannelPayload
|
102 | 106 | from .types.channel import VoiceChannel as VoiceChannelPayload
|
| 107 | + from .types.channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend |
103 | 108 | from .types.snowflake import SnowflakeList
|
104 | 109 | from .types.threads import ThreadArchiveDuration
|
105 | 110 | from .ui.view import View
|
@@ -2243,6 +2248,25 @@ async def set_status(
|
2243 | 2248 | """
|
2244 | 2249 | await self._state.http.set_voice_channel_status(self.id, status, reason=reason)
|
2245 | 2250 |
|
| 2251 | + async def send_soundboard_sound(self, sound: PartialSoundboardSound) -> None: |
| 2252 | + """|coro| |
| 2253 | +
|
| 2254 | + Sends a soundboard sound to the voice channel. |
| 2255 | +
|
| 2256 | + Parameters |
| 2257 | + ---------- |
| 2258 | + sound: :class:`PartialSoundboardSound` |
| 2259 | + The soundboard sound to send. |
| 2260 | +
|
| 2261 | + Raises |
| 2262 | + ------ |
| 2263 | + Forbidden |
| 2264 | + You do not have proper permissions to send the soundboard sound. |
| 2265 | + HTTPException |
| 2266 | + Sending the soundboard sound failed. |
| 2267 | + """ |
| 2268 | + await self._state.http.send_soundboard_sound(self.id, sound) |
| 2269 | + |
2246 | 2270 |
|
2247 | 2271 | class StageChannel(discord.abc.Messageable, VocalGuildChannel):
|
2248 | 2272 | """Represents a Discord guild stage channel.
|
@@ -3491,6 +3515,84 @@ def __repr__(self) -> str:
|
3491 | 3515 | return f"<PartialMessageable id={self.id} type={self.type!r}>"
|
3492 | 3516 |
|
3493 | 3517 |
|
| 3518 | +class VoiceChannelEffectAnimation(NamedTuple): |
| 3519 | + """Represents an animation that can be sent to a voice channel. |
| 3520 | +
|
| 3521 | + .. versionadded:: 2.7 |
| 3522 | + """ |
| 3523 | + |
| 3524 | + id: int |
| 3525 | + type: VoiceChannelEffectAnimationType |
| 3526 | + |
| 3527 | + |
| 3528 | +class VoiceChannelSoundEffect(PartialSoundboardSound): ... |
| 3529 | + |
| 3530 | + |
| 3531 | +class VoiceChannelEffectSendEvent: |
| 3532 | + """Represents the payload for an :func:`on_voice_channel_effect_send`. |
| 3533 | +
|
| 3534 | + .. versionadded:: 2.7 |
| 3535 | +
|
| 3536 | + Attributes |
| 3537 | + ---------- |
| 3538 | + animation_type: :class:`int` |
| 3539 | + The type of animation that is being sent. |
| 3540 | + animation_id: :class:`int` |
| 3541 | + The ID of the animation that is being sent. |
| 3542 | + sound: Optional[:class:`SoundboardSound`] |
| 3543 | + The sound that is being sent, could be ``None`` if the effect is not a sound effect. |
| 3544 | + guild: :class:`Guild` |
| 3545 | + The guild in which the sound is being sent. |
| 3546 | + user: :class:`Member` |
| 3547 | + The member that sent the sound. |
| 3548 | + channel: :class:`VoiceChannel` |
| 3549 | + The voice channel in which the sound is being sent. |
| 3550 | + data: :class:`dict` |
| 3551 | + The raw data sent by the gateway. |
| 3552 | + """ |
| 3553 | + |
| 3554 | + __slots__ = ( |
| 3555 | + "_state", |
| 3556 | + "animation_type", |
| 3557 | + "animation_id", |
| 3558 | + "sound", |
| 3559 | + "guild", |
| 3560 | + "user", |
| 3561 | + "channel", |
| 3562 | + "data", |
| 3563 | + "emoji", |
| 3564 | + ) |
| 3565 | + |
| 3566 | + def __init__( |
| 3567 | + self, |
| 3568 | + data: VoiceChannelEffectSend, |
| 3569 | + state: ConnectionState, |
| 3570 | + sound: SoundboardSound | PartialSoundboardSound | None = None, |
| 3571 | + ) -> None: |
| 3572 | + self._state = state |
| 3573 | + channel_id = int(data["channel_id"]) |
| 3574 | + user_id = int(data["user_id"]) |
| 3575 | + guild_id = int(data["guild_id"]) |
| 3576 | + self.animation_type: VoiceChannelEffectAnimationType = try_enum( |
| 3577 | + VoiceChannelEffectAnimationType, data["animation_type"] |
| 3578 | + ) |
| 3579 | + self.animation_id = int(data["animation_id"]) |
| 3580 | + self.sound = sound |
| 3581 | + self.guild = state._get_guild(guild_id) |
| 3582 | + self.user = self.guild.get_member(user_id) |
| 3583 | + self.channel = self.guild.get_channel(channel_id) |
| 3584 | + self.emoji = ( |
| 3585 | + PartialEmoji( |
| 3586 | + name=data["emoji"]["name"], |
| 3587 | + animated=data["emoji"]["animated"], |
| 3588 | + id=data["emoji"]["id"], |
| 3589 | + ) |
| 3590 | + if data.get("emoji", None) |
| 3591 | + else None |
| 3592 | + ) |
| 3593 | + self.data = data |
| 3594 | + |
| 3595 | + |
3494 | 3596 | def _guild_channel_factory(channel_type: int):
|
3495 | 3597 | value = try_enum(ChannelType, channel_type)
|
3496 | 3598 | if value is ChannelType.text:
|
|
0 commit comments