Back to top

hikari.voices

Application and entities that are used to describe voice state on Discord.

View Source
# -*- coding: utf-8 -*-
# cython: language_level=3
# Copyright (c) 2020 Nekokatt
# Copyright (c) 2021-present davfsa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Application and entities that are used to describe voice state on Discord."""

from __future__ import annotations

__all__: typing.Sequence[str] = ("VoiceRegion", "VoiceState")

import typing

import attr

from hikari.internal import attr_extensions

if typing.TYPE_CHECKING:
    import datetime

    from hikari import guilds
    from hikari import snowflakes
    from hikari import traits


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceState:
    """Represents a user's voice connection status."""

    app: traits.RESTAware = attr.field(
        repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True}
    )
    """The client application that models may use for procedures."""

    channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True)
    """The ID of the channel this user is connected to.

    This will be `None` if they are leaving voice.
    """

    guild_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True)
    """The ID of the guild this voice state is in."""

    is_guild_deafened: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is deafened by the guild."""

    is_guild_muted: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is muted by the guild."""

    is_self_deafened: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is deafened by their client."""

    is_self_muted: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is muted by their client."""

    is_streaming: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is streaming using "Go Live"."""

    is_suppressed: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is considered to be "suppressed" in a voice context.

    In the context of a voice channel this may mean that the user is muted by
    the current user and in the context of a stage channel this means that the
    user is not a speaker."""

    is_video_enabled: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user's camera is enabled."""

    user_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True)
    """The ID of the user this voice state is for."""

    member: guilds.Member = attr.field(eq=False, hash=False, repr=False)
    """The guild member this voice state is for."""

    session_id: str = attr.field(hash=True, repr=True)
    """The string ID of this voice state's session."""

    requested_to_speak_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=True)
    """When the user requested to speak in a stage channel.

    Will be `None` if they have not requested to speak.
    """


@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceRegion:
    """Represents a voice region server."""

    id: str = attr.field(hash=True, repr=True)
    """The string ID of this region.

    .. note::
        Unlike most parts of this API, this ID will always be a string type.
        This is intentional.
    """

    name: str = attr.field(eq=False, hash=False, repr=True)
    """The name of this region."""

    is_optimal_location: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region's server is closest to the current user's client."""

    is_deprecated: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region is deprecated."""

    is_custom: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region is custom (e.g. used for events)."""

    def __str__(self) -> str:
        return self.id
#  
@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceRegion:
View Source
@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceRegion:
    """Represents a voice region server."""

    id: str = attr.field(hash=True, repr=True)
    """The string ID of this region.

    .. note::
        Unlike most parts of this API, this ID will always be a string type.
        This is intentional.
    """

    name: str = attr.field(eq=False, hash=False, repr=True)
    """The name of this region."""

    is_optimal_location: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region's server is closest to the current user's client."""

    is_deprecated: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region is deprecated."""

    is_custom: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this region is custom (e.g. used for events)."""

    def __str__(self) -> str:
        return self.id

Represents a voice region server.

Variables and properties
#  id: str

The string ID of this region.

Note: Unlike most parts of this API, this ID will always be a string type. This is intentional.

#  is_custom: bool

Whether this region is custom (e.g. used for events).

#  is_deprecated: bool

Whether this region is deprecated.

#  is_optimal_location: bool

Whether this region's server is closest to the current user's client.

#  name: str

The name of this region.

Methods
#  def __init__(
   self,
   *,
   id: str,
   name: str,
   is_optimal_location: bool,
   is_deprecated: bool,
   is_custom: bool
):
View Source
def __init__(self, *, id, name, is_optimal_location, is_deprecated, is_custom):
    self.id = id
    self.name = name
    self.is_optimal_location = is_optimal_location
    self.is_deprecated = is_deprecated
    self.is_custom = is_custom

Method generated by attrs for class VoiceRegion.

#  
@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceState:
View Source
@attr_extensions.with_copy
@attr.define(hash=True, kw_only=True, weakref_slot=False)
class VoiceState:
    """Represents a user's voice connection status."""

    app: traits.RESTAware = attr.field(
        repr=False, eq=False, hash=False, metadata={attr_extensions.SKIP_DEEP_COPY: True}
    )
    """The client application that models may use for procedures."""

    channel_id: typing.Optional[snowflakes.Snowflake] = attr.field(eq=False, hash=False, repr=True)
    """The ID of the channel this user is connected to.

    This will be `None` if they are leaving voice.
    """

    guild_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True)
    """The ID of the guild this voice state is in."""

    is_guild_deafened: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is deafened by the guild."""

    is_guild_muted: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is muted by the guild."""

    is_self_deafened: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is deafened by their client."""

    is_self_muted: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is muted by their client."""

    is_streaming: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is streaming using "Go Live"."""

    is_suppressed: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user is considered to be "suppressed" in a voice context.

    In the context of a voice channel this may mean that the user is muted by
    the current user and in the context of a stage channel this means that the
    user is not a speaker."""

    is_video_enabled: bool = attr.field(eq=False, hash=False, repr=False)
    """Whether this user's camera is enabled."""

    user_id: snowflakes.Snowflake = attr.field(eq=False, hash=False, repr=True)
    """The ID of the user this voice state is for."""

    member: guilds.Member = attr.field(eq=False, hash=False, repr=False)
    """The guild member this voice state is for."""

    session_id: str = attr.field(hash=True, repr=True)
    """The string ID of this voice state's session."""

    requested_to_speak_at: typing.Optional[datetime.datetime] = attr.field(eq=False, hash=False, repr=True)
    """When the user requested to speak in a stage channel.

    Will be `None` if they have not requested to speak.
    """

Represents a user's voice connection status.

Variables and properties

The client application that models may use for procedures.

#  channel_id: Optional[hikari.snowflakes.Snowflake]

The ID of the channel this user is connected to.

This will be None if they are leaving voice.

The ID of the guild this voice state is in.

#  is_guild_deafened: bool

Whether this user is deafened by the guild.

#  is_guild_muted: bool

Whether this user is muted by the guild.

#  is_self_deafened: bool

Whether this user is deafened by their client.

#  is_self_muted: bool

Whether this user is muted by their client.

#  is_streaming: bool

Whether this user is streaming using "Go Live".

#  is_suppressed: bool

Whether this user is considered to be "suppressed" in a voice context.

In the context of a voice channel this may mean that the user is muted by the current user and in the context of a stage channel this means that the user is not a speaker.

#  is_video_enabled: bool

Whether this user's camera is enabled.

The guild member this voice state is for.

#  requested_to_speak_at: Optional[datetime.datetime]

When the user requested to speak in a stage channel.

Will be None if they have not requested to speak.

#  session_id: str

The string ID of this voice state's session.

The ID of the user this voice state is for.

Methods
#  def __init__(
   self,
   *,
   app: hikari.traits.RESTAware,
   channel_id: Optional[hikari.snowflakes.Snowflake],
   guild_id: hikari.snowflakes.Snowflake,
   is_guild_deafened: bool,
   is_guild_muted: bool,
   is_self_deafened: bool,
   is_self_muted: bool,
   is_streaming: bool,
   is_suppressed: bool,
   is_video_enabled: bool,
   user_id: hikari.snowflakes.Snowflake,
   member: hikari.guilds.Member,
   session_id: str,
   requested_to_speak_at: Optional[datetime.datetime]
):
View Source
def __init__(self, *, app, channel_id, guild_id, is_guild_deafened, is_guild_muted, is_self_deafened, is_self_muted, is_streaming, is_suppressed, is_video_enabled, user_id, member, session_id, requested_to_speak_at):
    self.app = app
    self.channel_id = channel_id
    self.guild_id = guild_id
    self.is_guild_deafened = is_guild_deafened
    self.is_guild_muted = is_guild_muted
    self.is_self_deafened = is_self_deafened
    self.is_self_muted = is_self_muted
    self.is_streaming = is_streaming
    self.is_suppressed = is_suppressed
    self.is_video_enabled = is_video_enabled
    self.user_id = user_id
    self.member = member
    self.session_id = session_id
    self.requested_to_speak_at = requested_to_speak_at

Method generated by attrs for class VoiceState.