Events relating to specific shards events.

This module

Expand source code
Browse git
# -*- 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.
"""Events relating to specific shards events."""

from __future__ import annotations

__all__: typing.Sequence[str] = (
    "ShardEvent",
    "ShardPayloadEvent",
    "ShardStateEvent",
    "ShardConnectedEvent",
    "ShardDisconnectedEvent",
    "ShardReadyEvent",
    "ShardResumedEvent",
    "MemberChunkEvent",
)

import abc
import typing

import attr

from hikari.events import base_events
from hikari.internal import attr_extensions
from hikari.internal import collections

if typing.TYPE_CHECKING:
    from hikari import applications
    from hikari import guilds
    from hikari import presences as presences_
    from hikari import snowflakes
    from hikari import traits
    from hikari import users
    from hikari.api import shard as gateway_shard


class ShardEvent(base_events.Event, abc.ABC):
    """Base class for any event that was shard-specific."""

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def shard(self) -> gateway_shard.GatewayShard:
        """Shard that received this event.

        Returns
        -------
        hikari.api.shard.GatewayShard
            The shard that triggered the event.
        """


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class ShardPayloadEvent(ShardEvent):
    """Event fired for most shard events with their raw payload.

    !!! note
        This will only be dispatched for real dispatch events received from
        Discord and not artificial events like the `ShardStateEvent` events.
    """

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    name: str = attr.field()
    """Name of the received event."""

    payload: typing.Mapping[str, typing.Any] = attr.field()
    """The raw payload for this event."""


class ShardStateEvent(ShardEvent, abc.ABC):
    """Base class for any event concerning the state/connectivity of a shard.

    This currently wraps connection/disconnection/ready/resumed events only.
    """

    __slots__: typing.Sequence[str] = ()


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class ShardConnectedEvent(ShardStateEvent):
    """Event fired when a shard connects."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class ShardDisconnectedEvent(ShardStateEvent):
    """Event fired when a shard disconnects."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class ShardReadyEvent(ShardStateEvent):
    """Event fired when a shard declares it is ready."""

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    actual_gateway_version: int = attr.field(repr=True)
    """Actual gateway version being used.

    Returns
    -------
    builtins.int
        The actual gateway version we are actively using for this protocol.
    """

    resume_gateway_url: str = attr.field(repr=False)
    """The URL to use to when reconnecting to the gateway."""

    session_id: str = attr.field(repr=True)
    """ID for this session.

    Returns
    -------
    builtins.str
        The session ID for this gateway session.
    """

    my_user: users.OwnUser = attr.field(repr=True)
    """User for the current bot account this connection is authenticated with.

    Returns
    -------
    hikari.users.OwnUser
        This bot's user.
    """

    unavailable_guilds: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=False)
    """Sequence of the IDs for all guilds this bot is currently in.

    All guilds will start off "unavailable" and should become available after
    a few seconds of connecting one-by-one.

    Returns
    -------
    typing.Sequence[hikari.snowflakes.Snowflake]
        All guild IDs that the bot is in for this shard.
    """

    application_id: snowflakes.Snowflake = attr.field(repr=True)
    """ID of the application this ready event is for.

    Returns
    -------
    hikari.snowflakes.Snowflake
        The current application's ID.
    """

    application_flags: applications.ApplicationFlags = attr.field(repr=True)
    """Flags of the application this ready event is for.

    Returns
    -------
    hikari.applications.ApplicationFlags
        The current application's flags.
    """

    @property
    def app(self) -> traits.RESTAware:
        # <<inherited docstring from Event>>.
        return self.my_user.app


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class ShardResumedEvent(ShardStateEvent):
    """Event fired when a shard resumes an existing session."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class MemberChunkEvent(ShardEvent, typing.Sequence["guilds.Member"]):
    """Event fired when a member chunk payload is received on a gateway shard."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    guild_id: snowflakes.Snowflake = attr.field(repr=True)
    # <<docstring inherited from ShardEvent>>.

    members: typing.Mapping[snowflakes.Snowflake, guilds.Member] = attr.field(repr=False)
    """Mapping of user IDs to the objects of the members in this chunk.

    Returns
    -------
    typing.Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Member]
        Mapping of user IDs to corresponding member objects.
    """

    chunk_index: int = attr.field(repr=True)
    """Zero-indexed position of this within the queued up chunks for this request.

    Returns
    -------
    builtins.int
        The sequence index for this chunk.
    """

    chunk_count: int = attr.field(repr=True)
    """Total number of expected chunks for the request this is associated with.

    Returns
    -------
    builtins.int
        Total number of chunks to be expected.
    """

    not_found: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=True)
    """Sequence of the snowflakes that were not found while making this request.

    This is only applicable when user IDs are specified while making the
    member request the chunk is associated with.

    Returns
    -------
    typing.Sequence[hikari.snowflakes.Snowflake]
        Sequence of user IDs that were not found.
    """

    presences: typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence] = attr.field(repr=False)
    """Mapping of user IDs to found member presence objects.

    This will be empty if no presences are found or `include_presences` is not passed as
    `builtins.True` while requesting the member chunks.

    Returns
    -------
    typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]
        Mapping of user IDs to corresponding presences.
    """

    nonce: typing.Optional[str] = attr.field(repr=True)
    """String nonce used to identify the request member chunks are associated with.

    This is the nonce value passed while requesting member chunks.

    Returns
    -------
    typing.Optional[builtins.str]
        The request nonce if set, or `builtins.None` otherwise.
    """

    @typing.overload
    def __getitem__(self, index_or_slice: int, /) -> guilds.Member:
        ...

    @typing.overload
    def __getitem__(self, index_or_slice: slice, /) -> typing.Sequence[guilds.Member]:
        ...

    def __getitem__(
        self, index_or_slice: typing.Union[int, slice], /
    ) -> typing.Union[guilds.Member, typing.Sequence[guilds.Member]]:
        return collections.get_index_or_slice(self.members, index_or_slice)

    def __iter__(self) -> typing.Iterator[guilds.Member]:
        return iter(self.members.values())

    def __len__(self) -> int:
        return len(self.members)

Classes

dataclass MemberChunkEvent

class MemberChunkEvent (
    *,
    app: traits.RESTAware,
    shard: gateway_shard.GatewayShard,
    guild_id: snowflakes.Snowflake,
    members: Mapping[snowflakes.Snowflakeguilds.Member],
    chunk_index: int,
    chunk_count: int,
    not_found: Sequence[snowflakes.Snowflake],
    presences: Mapping[snowflakes.Snowflakepresences_.MemberPresence],
    nonce: Optional[str],
): ...

Event fired when a member chunk payload is received on a gateway shard.

Method generated by attrs for class MemberChunkEvent.

Expand source code
Browse git
class MemberChunkEvent(ShardEvent, typing.Sequence["guilds.Member"]):
    """Event fired when a member chunk payload is received on a gateway shard."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    guild_id: snowflakes.Snowflake = attr.field(repr=True)
    # <<docstring inherited from ShardEvent>>.

    members: typing.Mapping[snowflakes.Snowflake, guilds.Member] = attr.field(repr=False)
    """Mapping of user IDs to the objects of the members in this chunk.

    Returns
    -------
    typing.Mapping[hikari.snowflakes.Snowflake, hikari.guilds.Member]
        Mapping of user IDs to corresponding member objects.
    """

    chunk_index: int = attr.field(repr=True)
    """Zero-indexed position of this within the queued up chunks for this request.

    Returns
    -------
    builtins.int
        The sequence index for this chunk.
    """

    chunk_count: int = attr.field(repr=True)
    """Total number of expected chunks for the request this is associated with.

    Returns
    -------
    builtins.int
        Total number of chunks to be expected.
    """

    not_found: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=True)
    """Sequence of the snowflakes that were not found while making this request.

    This is only applicable when user IDs are specified while making the
    member request the chunk is associated with.

    Returns
    -------
    typing.Sequence[hikari.snowflakes.Snowflake]
        Sequence of user IDs that were not found.
    """

    presences: typing.Mapping[snowflakes.Snowflake, presences_.MemberPresence] = attr.field(repr=False)
    """Mapping of user IDs to found member presence objects.

    This will be empty if no presences are found or `include_presences` is not passed as
    `builtins.True` while requesting the member chunks.

    Returns
    -------
    typing.Mapping[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]
        Mapping of user IDs to corresponding presences.
    """

    nonce: typing.Optional[str] = attr.field(repr=True)
    """String nonce used to identify the request member chunks are associated with.

    This is the nonce value passed while requesting member chunks.

    Returns
    -------
    typing.Optional[builtins.str]
        The request nonce if set, or `builtins.None` otherwise.
    """

    @typing.overload
    def __getitem__(self, index_or_slice: int, /) -> guilds.Member:
        ...

    @typing.overload
    def __getitem__(self, index_or_slice: slice, /) -> typing.Sequence[guilds.Member]:
        ...

    def __getitem__(
        self, index_or_slice: typing.Union[int, slice], /
    ) -> typing.Union[guilds.Member, typing.Sequence[guilds.Member]]:
        return collections.get_index_or_slice(self.members, index_or_slice)

    def __iter__(self) -> typing.Iterator[guilds.Member]:
        return iter(self.members.values())

    def __len__(self) -> int:
        return len(self.members)
Method resolution order
dataclass MemberChunkEvent
That's this class!
abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

extern class collections.abc.Sequence

All the operations on a read-only sequence …

extern class collections.abc.Reversible
extern class collections.abc.Collection
extern class collections.abc.Sized
extern class collections.abc.Iterable
extern class collections.abc.Container
extern class Generic

Abstract base class for generic types …

Variables and properties
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property chunk_countint

Total number of expected chunks for the request this is associated with.

Returns

int
Total number of chunks to be expected.
property chunk_indexint

Zero-indexed position of this within the queued up chunks for this request.

Returns

int
The sequence index for this chunk.
property guild_idsnowflakes.Snowflake

Return an attribute of instance, which is of type owner.

property membersMapping[snowflakes.Snowflake, guilds.Member]

Mapping of user IDs to the objects of the members in this chunk.

Returns

Mapping[Snowflake, Member]
Mapping of user IDs to corresponding member objects.
property nonceOptional[str]

String nonce used to identify the request member chunks are associated with.

This is the nonce value passed while requesting member chunks.

Returns

Optional[str]
The request nonce if set, or None otherwise.
property not_foundSequence[snowflakes.Snowflake]

Sequence of the snowflakes that were not found while making this request.

This is only applicable when user IDs are specified while making the member request the chunk is associated with.

Returns

Sequence[Snowflake]
Sequence of user IDs that were not found.
property presencesMapping[snowflakes.Snowflake, presences_.MemberPresence]

Mapping of user IDs to found member presence objects.

This will be empty if no presences are found or include_presences is not passed as True while requesting the member chunks.

Returns

Mapping[Snowflake, MemberPresence]
Mapping of user IDs to corresponding presences.
property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass ShardConnectedEvent

class ShardConnectedEvent (
    *,
    app: traits.RESTAware,
    shard: gateway_shard.GatewayShard,
): ...

Event fired when a shard connects.

Method generated by attrs for class ShardConnectedEvent.

Expand source code
Browse git
class ShardConnectedEvent(ShardStateEvent):
    """Event fired when a shard connects."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.
Method resolution order
dataclass ShardConnectedEvent
That's this class!
abstract class ShardStateEvent

Base class for any event concerning the state/connectivity of a shard …

abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardStateEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardStateEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass ShardDisconnectedEvent

class ShardDisconnectedEvent (
    *,
    app: traits.RESTAware,
    shard: gateway_shard.GatewayShard,
): ...

Event fired when a shard disconnects.

Method generated by attrs for class ShardDisconnectedEvent.

Expand source code
Browse git
class ShardDisconnectedEvent(ShardStateEvent):
    """Event fired when a shard disconnects."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.
Method resolution order
dataclass ShardDisconnectedEvent
That's this class!
abstract class ShardStateEvent

Base class for any event concerning the state/connectivity of a shard …

abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardStateEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardStateEvent.dispatches

Sequence of the event classes this event is dispatched as.

class ShardEvent

class ShardEvent: ...

Base class for any event that was shard-specific.

Expand source code
Browse git
class ShardEvent(base_events.Event, abc.ABC):
    """Base class for any event that was shard-specific."""

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def shard(self) -> gateway_shard.GatewayShard:
        """Shard that received this event.

        Returns
        -------
        hikari.api.shard.GatewayShard
            The shard that triggered the event.
        """
Subclasses
dataclass ApplicationCommandPermissionsUpdateEvent

Event fired when permissions for an application command are updated …

abstract class ChannelEvent

Event base for any channel-bound event in guilds or private messages …

abstract class GuildEvent

Event base for any guild-bound event …

dataclass PresenceUpdateEvent

Event fired when a user in a guild updates their presence in a guild …

dataclass InteractionCreateEvent

Event fired when an interaction is created …

abstract class MemberEvent

Event base for any events that concern guild members …

dataclass GuildBulkMessageDeleteEvent

Event that is triggered when a bulk deletion is triggered in a guild …

abstract class MessageEvent

Any event that concerns manipulation of messages …

abstract class ReactionEvent

Event base for any message reaction event …

abstract class RoleEvent

Event base for any event that involves guild roles …

abstract class ScheduledEventEvent

Event bassed for any scheduled event related events …

dataclass MemberChunkEvent

Event fired when a member chunk payload is received on a gateway shard …

dataclass ShardPayloadEvent

Event fired for most shard events with their raw payload …

abstract class ShardStateEvent

Base class for any event concerning the state/connectivity of a shard …

abstract class TypingEvent

Base event fired when a user begins typing in a channel …

dataclass OwnUserUpdateEvent

Event fired when the account user is updated …

abstract class VoiceEvent

Base for any voice-related event.

Method resolution order
abstract class ShardEvent
That's this class!
abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
abstract property appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
abstract property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: Event.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: Event.dispatches

Sequence of the event classes this event is dispatched as.

dataclass ShardPayloadEvent

class ShardPayloadEvent (
    *,
    app: traits.RESTAware,
    shard: gateway_shard.GatewayShard,
    name: str,
    payload: Mapping[strAny],
): ...

Event fired for most shard events with their raw payload.

Note

This will only be dispatched for real dispatch events received from Discord and not artificial events like the ShardStateEvent events.

Method generated by attrs for class ShardPayloadEvent.

Expand source code
Browse git
class ShardPayloadEvent(ShardEvent):
    """Event fired for most shard events with their raw payload.

    !!! note
        This will only be dispatched for real dispatch events received from
        Discord and not artificial events like the `ShardStateEvent` events.
    """

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    name: str = attr.field()
    """Name of the received event."""

    payload: typing.Mapping[str, typing.Any] = attr.field()
    """The raw payload for this event."""
Method resolution order
dataclass ShardPayloadEvent
That's this class!
abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property namestr

Name of the received event.

property payloadMapping[str, Any]

The raw payload for this event.

property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass ShardReadyEvent

class ShardReadyEvent (
    *,
    shard: gateway_shard.GatewayShard,
    actual_gateway_version: int,
    resume_gateway_url: str,
    session_id: str,
    my_user: users.OwnUser,
    unavailable_guilds: Sequence[snowflakes.Snowflake],
    application_id: snowflakes.Snowflake,
    application_flags: applications.ApplicationFlags,
): ...

Event fired when a shard declares it is ready.

Method generated by attrs for class ShardReadyEvent.

Expand source code
Browse git
class ShardReadyEvent(ShardStateEvent):
    """Event fired when a shard declares it is ready."""

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.

    actual_gateway_version: int = attr.field(repr=True)
    """Actual gateway version being used.

    Returns
    -------
    builtins.int
        The actual gateway version we are actively using for this protocol.
    """

    resume_gateway_url: str = attr.field(repr=False)
    """The URL to use to when reconnecting to the gateway."""

    session_id: str = attr.field(repr=True)
    """ID for this session.

    Returns
    -------
    builtins.str
        The session ID for this gateway session.
    """

    my_user: users.OwnUser = attr.field(repr=True)
    """User for the current bot account this connection is authenticated with.

    Returns
    -------
    hikari.users.OwnUser
        This bot's user.
    """

    unavailable_guilds: typing.Sequence[snowflakes.Snowflake] = attr.field(repr=False)
    """Sequence of the IDs for all guilds this bot is currently in.

    All guilds will start off "unavailable" and should become available after
    a few seconds of connecting one-by-one.

    Returns
    -------
    typing.Sequence[hikari.snowflakes.Snowflake]
        All guild IDs that the bot is in for this shard.
    """

    application_id: snowflakes.Snowflake = attr.field(repr=True)
    """ID of the application this ready event is for.

    Returns
    -------
    hikari.snowflakes.Snowflake
        The current application's ID.
    """

    application_flags: applications.ApplicationFlags = attr.field(repr=True)
    """Flags of the application this ready event is for.

    Returns
    -------
    hikari.applications.ApplicationFlags
        The current application's flags.
    """

    @property
    def app(self) -> traits.RESTAware:
        # <<inherited docstring from Event>>.
        return self.my_user.app
Method resolution order
dataclass ShardReadyEvent
That's this class!
abstract class ShardStateEvent

Base class for any event concerning the state/connectivity of a shard …

abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
property actual_gateway_versionint

Actual gateway version being used.

Returns

int
The actual gateway version we are actively using for this protocol.
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property application_flagsapplications.ApplicationFlags

Flags of the application this ready event is for.

Returns

ApplicationFlags
The current application's flags.
property application_idsnowflakes.Snowflake

ID of the application this ready event is for.

Returns

Snowflake
The current application's ID.
property my_userusers.OwnUser

User for the current bot account this connection is authenticated with.

Returns

OwnUser
This bot's user.
property resume_gateway_urlstr

The URL to use to when reconnecting to the gateway.

property session_idstr

ID for this session.

Returns

str
The session ID for this gateway session.
property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
property unavailable_guildsSequence[snowflakes.Snowflake]

Sequence of the IDs for all guilds this bot is currently in.

All guilds will start off "unavailable" and should become available after a few seconds of connecting one-by-one.

Returns

Sequence[Snowflake]
All guild IDs that the bot is in for this shard.
Methods
def bitmask() -> int: ...

Inherited from: ShardStateEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardStateEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass ShardResumedEvent

class ShardResumedEvent (
    *,
    app: traits.RESTAware,
    shard: gateway_shard.GatewayShard,
): ...

Event fired when a shard resumes an existing session.

Method generated by attrs for class ShardResumedEvent.

Expand source code
Browse git
class ShardResumedEvent(ShardStateEvent):
    """Event fired when a shard resumes an existing session."""

    app: traits.RESTAware = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<inherited docstring from Event>>.

    shard: gateway_shard.GatewayShard = attr.field(metadata={attr_extensions.SKIP_DEEP_COPY: True})
    # <<docstring inherited from ShardEvent>>.
Method resolution order
dataclass ShardResumedEvent
That's this class!
abstract class ShardStateEvent

Base class for any event concerning the state/connectivity of a shard …

abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
property apptraits.RESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardStateEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardStateEvent.dispatches

Sequence of the event classes this event is dispatched as.

class ShardStateEvent

class ShardStateEvent: ...

Base class for any event concerning the state/connectivity of a shard.

This currently wraps connection/disconnection/ready/resumed events only.

Expand source code
Browse git
class ShardStateEvent(ShardEvent, abc.ABC):
    """Base class for any event concerning the state/connectivity of a shard.

    This currently wraps connection/disconnection/ready/resumed events only.
    """

    __slots__: typing.Sequence[str] = ()
Subclasses
dataclass ShardConnectedEvent

Event fired when a shard connects …

dataclass ShardDisconnectedEvent

Event fired when a shard disconnects …

dataclass ShardReadyEvent

Event fired when a shard declares it is ready …

dataclass ShardResumedEvent

Event fired when a shard resumes an existing session …

Method resolution order
abstract class ShardStateEvent
That's this class!
abstract class ShardEvent

Base class for any event that was shard-specific.

abstract class Event

Base event type that all Hikari events should subclass.

extern class abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Variables and properties
abstract property appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
abstract property shardgateway_shard.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def bitmask() -> int: ...

Inherited from: ShardEvent.bitmask

Bitmask for this event.

def dispatches() -> Sequence[Type[Event]]: ...

Inherited from: ShardEvent.dispatches

Sequence of the event classes this event is dispatched as.