Events that fire if messages are sent/updated/deleted.

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 that fire if messages are sent/updated/deleted."""

from __future__ import annotations

__all__: typing.Sequence[str] = (
    "MessageEvent",
    "MessageCreateEvent",
    "MessageUpdateEvent",
    "MessageDeleteEvent",
    "GuildMessageCreateEvent",
    "GuildMessageUpdateEvent",
    "GuildMessageDeleteEvent",
    "GuildBulkMessageDeleteEvent",
    "DMMessageCreateEvent",
    "DMMessageUpdateEvent",
    "DMMessageDeleteEvent",
)

import abc
import typing

import attr

from hikari import channels
from hikari import intents
from hikari import snowflakes
from hikari import traits
from hikari import undefined
from hikari.events import base_events
from hikari.events import shard_events
from hikari.internal import attr_extensions

if typing.TYPE_CHECKING:
    from hikari import embeds as embeds_
    from hikari import guilds
    from hikari import messages
    from hikari import users
    from hikari.api import shard as shard_


@base_events.requires_intents(intents.Intents.DM_MESSAGES, intents.Intents.GUILD_MESSAGES)
class MessageEvent(shard_events.ShardEvent, abc.ABC):
    """Any event that concerns manipulation of messages."""

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def channel_id(self) -> snowflakes.Snowflake:
        """ID of the channel that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the channel that this event concerns.
        """

    @property
    @abc.abstractmethod
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """


@base_events.requires_intents(intents.Intents.DM_MESSAGES, intents.Intents.GUILD_MESSAGES)
class MessageCreateEvent(MessageEvent, abc.ABC):
    """Event that is fired when a message is created."""

    __slots__: typing.Sequence[str] = ()

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

    @property
    def author(self) -> users.User:
        """User that sent the message.

        Returns
        -------
        hikari.users.User
            The user that sent the message.
        """
        return self.message.author

    @property
    def author_id(self) -> snowflakes.Snowflake:
        """ID of the author of the message this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the author.
        """
        return self.author.id

    @property
    def channel_id(self) -> snowflakes.Snowflake:
        # <<inherited docstring from MessageEvent>>
        return self.message.channel_id

    @property
    def content(self) -> typing.Optional[str]:
        """Content of the message.

        Returns
        -------
        typing.Optional[builtins.str]
            The content of the message, if present. This may be `builtins.None`
            or an empty string (or any falsy value) if no content is present
            (e.g. if only an embed was sent).
        """
        return self.message.content

    @property
    def embeds(self) -> typing.Sequence[embeds_.Embed]:
        """Sequence of embeds in the message.

        Returns
        -------
        typing.Sequence[hikari.embeds.Embed]
            The embeds in the message.
        """
        return self.message.embeds

    @property
    def is_bot(self) -> bool:
        """Return `builtins.True` if the message is from a bot.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a bot, or `builtins.False` otherwise.
        """
        return self.message.author.is_bot

    @property
    def is_human(self) -> bool:
        """Return `builtins.True` if the message was created by a human.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a human user, or `builtins.False` otherwise.
        """
        # Not second-guessing some weird edge case will occur in the future with this,
        # so I am being safe rather than sorry.
        return not self.message.author.is_bot and self.message.webhook_id is None

    @property
    def is_webhook(self) -> bool:
        """Return `builtins.True` if the message was created by a webhook.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a webhook, or `builtins.False` otherwise.
        """
        return self.message.webhook_id is not None

    @property
    @abc.abstractmethod
    def message(self) -> messages.Message:
        """Message that was sent in the event.

        Returns
        -------
        hikari.messages.Message
            The message object that was sent with this event.
        """

    @property
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """
        return self.message.id


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.GUILD_MESSAGES)
class GuildMessageCreateEvent(MessageCreateEvent):
    """Event that is fired when a message is created within a guild.

    This contains the full message in the internal `message` attribute.
    """

    message: messages.Message = attr.field()
    # <<inherited docstring from MessageCreateEvent>>

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

    @property
    def author(self) -> users.User:
        """User object of the user that sent the message.

        Returns
        -------
        hikari.users.User
            The user object of the user that sent the message.
        """
        return self.message.author

    @property
    def member(self) -> typing.Optional[guilds.Member]:
        """Member object of the user that sent the message.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            The member object of the user that sent the message or
            `builtins.None` if sent by a webhook.
        """
        return self.message.member

    @property
    def guild_id(self) -> snowflakes.Snowflake:
        """ID of the guild that this event occurred in.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the guild that this event occurred in.
        """
        guild_id = self.message.guild_id
        # Always present on guild events
        assert isinstance(guild_id, snowflakes.Snowflake), "no guild_id attribute set"
        return guild_id

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Channel that the message was sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel that the message was sent in, if known and cached,
            otherwise, `builtins.None`.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild that this event occurred in, if known.

        !!! note
            This will require the `GUILDS` intent to be specified on start-up
            in order to be known.

        Returns
        -------
        typing.Optional[hikari.guilds.GatewayGuild]
            The guild that this event occurred in, if cached. Otherwise,
            `builtins.None` instead.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)

    def get_member(self) -> typing.Optional[guilds.Member]:
        """Get the member that sent this message from the cache if available.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            Cached object of the member that sent the message if found.
        """
        if isinstance(self.app, traits.CacheAware):
            return self.app.cache.get_member(self.guild_id, self.message.author.id)

        return None


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.DM_MESSAGES)
class DMMessageCreateEvent(MessageCreateEvent):
    """Event that is fired when a message is created within a DM.

    This contains the full message in the internal `message` attribute.
    """

    message: messages.Message = attr.field()
    # <<inherited docstring from MessageCreateEvent>>

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


@base_events.requires_intents(intents.Intents.DM_MESSAGES, intents.Intents.GUILD_MESSAGES)
class MessageUpdateEvent(MessageEvent, abc.ABC):
    """Event that is fired when a message is updated.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    __slots__: typing.Sequence[str] = ()

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

    @property
    def author(self) -> undefined.UndefinedOr[users.User]:
        """User that sent the message.

        This will be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        return self.message.author

    @property
    def author_id(self) -> undefined.UndefinedOr[snowflakes.Snowflake]:
        """ID of the author that triggered this event.

        This will be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        author = self.message.author
        return author.id if author is not undefined.UNDEFINED else undefined.UNDEFINED

    @property
    def channel_id(self) -> snowflakes.Snowflake:
        # <<inherited docstring from MessageEvent>>.
        return self.message.channel_id

    @property
    def content(self) -> undefined.UndefinedNoneOr[str]:
        """Content of the message.

        Returns
        -------
        hikari.undefined.UndefinedNoneOr[builtins.str]
            The content of the message, if present. This may be `builtins.None`
            or an empty string (or any falsy value) if no content is present
            (e.g. if only an embed was sent). If not part of the update, then
            this will be `hikari.undefined.UNDEFINED` instead.
        """
        return self.message.content

    @property
    def embeds(self) -> undefined.UndefinedOr[typing.Sequence[embeds_.Embed]]:
        """Sequence of embeds in the message.

        Returns
        -------
        hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]
            The embeds in the message. If the embeds were not changed in this
            event, then this may instead be `hikari.undefined.UNDEFINED`.
        """
        return self.message.embeds

    @property
    def is_bot(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message is from a bot.

        Returns
        -------
        typing.Optional[builtins.bool]
            `builtins.True` if from a bot, or `builtins.False` otherwise.

            If the author is not known, due to the update event being caused
            by Discord adding an embed preview to accompany a URL, then this
            will return `hikari.undefined.UNDEFINED` instead.
        """
        if (author := self.message.author) is not undefined.UNDEFINED:
            return author.is_bot

        return undefined.UNDEFINED

    @property
    def is_human(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message was created by a human.

        Returns
        -------
        typing.Optional[builtins.bool]
            `builtins.True` if from a human user, or `builtins.False` otherwise.

            If the author is not known, due to the update event being caused
            by Discord adding an embed preview to accompany a URL, then this
            may return `hikari.undefined.UNDEFINED` instead.
        """
        # Not second-guessing some weird edge case will occur in the future with this,
        # so I am being safe rather than sorry.
        if (webhook_id := self.message.webhook_id) is not undefined.UNDEFINED:
            return webhook_id is None

        if (author := self.message.author) is not undefined.UNDEFINED:
            return not author.is_bot

        return undefined.UNDEFINED

    @property
    def is_webhook(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message was created by a webhook.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a webhook, or `builtins.False` otherwise.
        """
        if (webhook_id := self.message.webhook_id) is not undefined.UNDEFINED:
            return webhook_id is not None

        return undefined.UNDEFINED

    @property
    @abc.abstractmethod
    def message(self) -> messages.PartialMessage:
        """Partial message that was sent in the event.

        Returns
        -------
        hikari.messages.PartialMessage
            The partial message object that was sent with this event.
        """

    @property
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """
        return self.message.id


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.GUILD_MESSAGES)
class GuildMessageUpdateEvent(MessageUpdateEvent):
    """Event that is fired when a message is updated in a guild.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    old_message: typing.Optional[messages.PartialMessage] = attr.field()
    """The old message object.

    This will be `builtins.None` if the message missing from the cache.
    """

    message: messages.PartialMessage = attr.field()
    # <<inherited docstring from MessageUpdateEvent>>

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

    @property
    def member(self) -> undefined.UndefinedNoneOr[guilds.Member]:
        """Member that sent the message if provided by the event.

        If the message is not in a guild, this will be `builtins.None`.

        This will also be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        return self.message.member

    def get_member(self) -> typing.Optional[guilds.Member]:
        """Get the member that sent this message from the cache if available.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            Cached object of the member that sent the message if found.
        """
        if self.message.author is not undefined.UNDEFINED and isinstance(self.app, traits.CacheAware):
            return self.app.cache.get_member(self.guild_id, self.message.author.id)

        return None

    @property
    def guild_id(self) -> snowflakes.Snowflake:
        """ID of the guild that this event occurred in.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the guild that this event occurred in.
        """
        guild_id = self.message.guild_id
        # Always present on guild events
        assert isinstance(guild_id, snowflakes.Snowflake), f"expected guild_id, got {guild_id}"
        return guild_id

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Channel that the message was sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel that the message was sent in, if known and cached,
            otherwise, `builtins.None`.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild that this event occurred in, if known.

        !!! note
            This will require the `GUILDS` intent to be specified on start-up
            in order to be known.

        Returns
        -------
        typing.Optional[hikari.guilds.GatewayGuild]
            The guild that this event occurred in, if cached. Otherwise,
            `builtins.None` instead.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.DM_MESSAGES)
class DMMessageUpdateEvent(MessageUpdateEvent):
    """Event that is fired when a message is updated in a DM.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    old_message: typing.Optional[messages.PartialMessage] = attr.field()
    """The old message object.

    This will be `builtins.None` if the message missing from the cache.
    """

    message: messages.PartialMessage = attr.field()
    # <<inherited docstring from MessageUpdateEvent>>

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


@base_events.requires_intents(intents.Intents.GUILD_MESSAGES, intents.Intents.DM_MESSAGES)
class MessageDeleteEvent(MessageEvent, abc.ABC):
    """Special event that is triggered when a message gets deleted.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that was deleted."""

    @property
    @abc.abstractmethod
    def old_message(self) -> typing.Optional[messages.Message]:
        """Object of the message that was deleted.

        Will be `None` if the message was not found in the cache.
        """


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.GUILD_MESSAGES)
class GuildMessageDeleteEvent(MessageDeleteEvent):
    """Event that is triggered if a message is deleted in a guild.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageEvent>>

    guild_id: snowflakes.Snowflake = attr.field()
    """ID of the guild that this event occurred in."""

    message_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

    old_message: typing.Optional[messages.Message] = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

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

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Get the cached channel the message were sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel the messages were sent in, or `builtins.None` if not
            known/cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild this event corresponds to, if known.

        !!! note
            You will need `hikari.intents.Intents.GUILDS` enabled to receive this
            information.

        Returns
        -------
        hikari.guilds.GatewayGuild
            The gateway guild that this event corresponds to, if known and
            cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.DM_MESSAGES)
class DMMessageDeleteEvent(MessageDeleteEvent):
    """Event that is triggered if a message is deleted in a DM.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageEvent>>

    message_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

    old_message: typing.Optional[messages.Message] = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

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


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
@base_events.requires_intents(intents.Intents.GUILD_MESSAGES)
class GuildBulkMessageDeleteEvent(shard_events.ShardEvent):
    """Event that is triggered when a bulk deletion is triggered in a guild.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    """ID of the channel that this event concerns."""

    guild_id: snowflakes.Snowflake = attr.field()
    """ID of the guild that this event occurred in."""

    message_ids: typing.AbstractSet[snowflakes.Snowflake] = attr.field()
    """Set of message IDs that were bulk deleted."""

    old_messages: typing.Mapping[snowflakes.Snowflake, messages.Message] = attr.field()
    """Mapping of a snowflake to the deleted message object.

    If the message was not found in the cache it will be missing from the mapping.
    """

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

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Get the cached channel the messages were sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel the messages were sent in, or `builtins.None` if not
            known/cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild this event corresponds to, if known.

        !!! note
            You will need `hikari.intents.Intents.GUILDS` enabled to receive this
            information.

        Returns
        -------
        hikari.guilds.GatewayGuild
            The gateway guild that this event corresponds to, if known and
            cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)

Classes

dataclass DMMessageCreateEvent

class DMMessageCreateEvent (
    *,
    message: messages.Message,
    shard: shard_.GatewayShard,
): ...

Event that is fired when a message is created within a DM.

This contains the full message in the internal message attribute.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class DMMessageCreateEvent.

Expand source code
Browse git
class DMMessageCreateEvent(MessageCreateEvent):
    """Event that is fired when a message is created within a DM.

    This contains the full message in the internal `message` attribute.
    """

    message: messages.Message = attr.field()
    # <<inherited docstring from MessageCreateEvent>>

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

Event that is fired when a message is created …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorusers.User

User that sent the message.

Returns

User
The user that sent the message.
property author_idSnowflake

ID of the author of the message this event concerns.

Returns

Snowflake
The ID of the author.
property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Optional[str]

Content of the message.

Returns

Optional[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent).
property embedsSequence[embeds_.Embed]

Sequence of embeds in the message.

Returns

Sequence[Embed]
The embeds in the message.
property is_botbool

Return True if the message is from a bot.

Returns

bool
True if from a bot, or False otherwise.
property is_humanbool

Return True if the message was created by a human.

Returns

bool
True if from a human user, or False otherwise.
property is_webhookbool

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
property messagemessages.Message

Message that was sent in the event.

Returns

Message
The message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
property shardshard_.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageCreateEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageCreateEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass DMMessageDeleteEvent

class DMMessageDeleteEvent (
    *,
    app: traits.RESTAware,
    channel_id: snowflakes.Snowflake,
    message_id: snowflakes.Snowflake,
    old_message: Optional[messages.Message],
    shard: shard_.GatewayShard,
): ...

Event that is triggered if a message is deleted in a DM.

Note

Due to Discord limitations, most message information is unavailable during deletion events.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class DMMessageDeleteEvent.

Expand source code
Browse git
class DMMessageDeleteEvent(MessageDeleteEvent):
    """Event that is triggered if a message is deleted in a DM.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageEvent>>

    message_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

    old_message: typing.Optional[messages.Message] = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

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

Special event that is triggered when a message gets deleted …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 channel_idsnowflakes.Snowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property message_idsnowflakes.Snowflake

ID of the message that was deleted.

property old_messageOptional[messages.Message]

Object of the message that was deleted.

Will be None if the message was not found in the cache.

property shardshard_.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageDeleteEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageDeleteEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass DMMessageUpdateEvent

class DMMessageUpdateEvent (
    *,
    old_message: Optional[messages.PartialMessage],
    message: messages.PartialMessage,
    shard: shard_.GatewayShard,
): ...

Event that is fired when a message is updated in a DM.

Note

Less information will be available here than in the creation event due to Discord limitations.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class DMMessageUpdateEvent.

Expand source code
Browse git
class DMMessageUpdateEvent(MessageUpdateEvent):
    """Event that is fired when a message is updated in a DM.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    old_message: typing.Optional[messages.PartialMessage] = attr.field()
    """The old message object.

    This will be `builtins.None` if the message missing from the cache.
    """

    message: messages.PartialMessage = attr.field()
    # <<inherited docstring from MessageUpdateEvent>>

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

Event that is fired when a message is updated …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorundefined.UndefinedOr[users.User]

User that sent the message.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property author_id : Union[SnowflakeUndefinedType]

ID of the author that triggered this event.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Union[strUndefinedTypeNone]

Content of the message.

Returns

UndefinedNoneOr[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent). If not part of the update, then this will be UNDEFINED instead.
property embedsundefined.UndefinedOr[Sequence[embeds_.Embed]]

Sequence of embeds in the message.

Returns

UndefinedOr[Sequence[Embed]]
The embeds in the message. If the embeds were not changed in this event, then this may instead be UNDEFINED.
property is_bot : Union[boolUndefinedType]

Return True if the message is from a bot.

Returns

Optional[bool]

True if from a bot, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this will return UNDEFINED instead.

property is_human : Union[boolUndefinedType]

Return True if the message was created by a human.

Returns

Optional[bool]

True if from a human user, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this may return UNDEFINED instead.

property is_webhook : Union[boolUndefinedType]

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
property messagemessages.PartialMessage

Partial message that was sent in the event.

Returns

PartialMessage
The partial message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
property old_messageOptional[messages.PartialMessage]

The old message object.

This will be None if the message missing from the cache.

property shardshard_.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageUpdateEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageUpdateEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass GuildBulkMessageDeleteEvent

class GuildBulkMessageDeleteEvent (
    *,
    app: traits.RESTAware,
    channel_id: snowflakes.Snowflake,
    guild_id: snowflakes.Snowflake,
    message_ids: AbstractSet[snowflakes.Snowflake],
    old_messages: Mapping[snowflakes.Snowflakemessages.Message],
    shard: shard_.GatewayShard,
): ...

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

Note

Due to Discord limitations, most message information is unavailable during deletion events.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class GuildBulkMessageDeleteEvent.

Expand source code
Browse git
class GuildBulkMessageDeleteEvent(shard_events.ShardEvent):
    """Event that is triggered when a bulk deletion is triggered in a guild.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    """ID of the channel that this event concerns."""

    guild_id: snowflakes.Snowflake = attr.field()
    """ID of the guild that this event occurred in."""

    message_ids: typing.AbstractSet[snowflakes.Snowflake] = attr.field()
    """Set of message IDs that were bulk deleted."""

    old_messages: typing.Mapping[snowflakes.Snowflake, messages.Message] = attr.field()
    """Mapping of a snowflake to the deleted message object.

    If the message was not found in the cache it will be missing from the mapping.
    """

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

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Get the cached channel the messages were sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel the messages were sent in, or `builtins.None` if not
            known/cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild this event corresponds to, if known.

        !!! note
            You will need `hikari.intents.Intents.GUILDS` enabled to receive this
            information.

        Returns
        -------
        hikari.guilds.GatewayGuild
            The gateway guild that this event corresponds to, if known and
            cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)
Method resolution order
dataclass GuildBulkMessageDeleteEvent
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 channel_idsnowflakes.Snowflake

ID of the channel that this event concerns.

property guild_idsnowflakes.Snowflake

ID of the guild that this event occurred in.

property message_idsAbstractSet[snowflakes.Snowflake]

Set of message IDs that were bulk deleted.

property old_messagesMapping[snowflakes.Snowflake, messages.Message]

Mapping of a snowflake to the deleted message object.

If the message was not found in the cache it will be missing from the mapping.

property shardshard_.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def get_channel() -> Optional[TextableGuildChannel]: ...

Get the cached channel the messages were sent in, if known.

Returns

Optional[TextableGuildChannel]
The channel the messages were sent in, or None if not known/cached.
Expand source code
Browse git
def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
    """Get the cached channel the messages were sent in, if known.

    Returns
    -------
    typing.Optional[hikari.channels.TextableGuildChannel]
        The channel the messages were sent in, or `builtins.None` if not
        known/cached.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    channel = self.app.cache.get_guild_channel(self.channel_id)
    assert channel is None or isinstance(
        channel, channels.TextableGuildChannel
    ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
    return channel
def get_guild() -> Optional[guilds.GatewayGuild]: ...

Get the cached guild this event corresponds to, if known.

Note

You will need GUILDS enabled to receive this information.

Returns

GatewayGuild
The gateway guild that this event corresponds to, if known and cached.
Expand source code
Browse git
def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
    """Get the cached guild this event corresponds to, if known.

    !!! note
        You will need `hikari.intents.Intents.GUILDS` enabled to receive this
        information.

    Returns
    -------
    hikari.guilds.GatewayGuild
        The gateway guild that this event corresponds to, if known and
        cached.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    return self.app.cache.get_guild(self.guild_id)
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 GuildMessageCreateEvent

class GuildMessageCreateEvent (
    *,
    message: messages.Message,
    shard: shard_.GatewayShard,
): ...

Event that is fired when a message is created within a guild.

This contains the full message in the internal message attribute.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class GuildMessageCreateEvent.

Expand source code
Browse git
class GuildMessageCreateEvent(MessageCreateEvent):
    """Event that is fired when a message is created within a guild.

    This contains the full message in the internal `message` attribute.
    """

    message: messages.Message = attr.field()
    # <<inherited docstring from MessageCreateEvent>>

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

    @property
    def author(self) -> users.User:
        """User object of the user that sent the message.

        Returns
        -------
        hikari.users.User
            The user object of the user that sent the message.
        """
        return self.message.author

    @property
    def member(self) -> typing.Optional[guilds.Member]:
        """Member object of the user that sent the message.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            The member object of the user that sent the message or
            `builtins.None` if sent by a webhook.
        """
        return self.message.member

    @property
    def guild_id(self) -> snowflakes.Snowflake:
        """ID of the guild that this event occurred in.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the guild that this event occurred in.
        """
        guild_id = self.message.guild_id
        # Always present on guild events
        assert isinstance(guild_id, snowflakes.Snowflake), "no guild_id attribute set"
        return guild_id

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Channel that the message was sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel that the message was sent in, if known and cached,
            otherwise, `builtins.None`.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild that this event occurred in, if known.

        !!! note
            This will require the `GUILDS` intent to be specified on start-up
            in order to be known.

        Returns
        -------
        typing.Optional[hikari.guilds.GatewayGuild]
            The guild that this event occurred in, if cached. Otherwise,
            `builtins.None` instead.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)

    def get_member(self) -> typing.Optional[guilds.Member]:
        """Get the member that sent this message from the cache if available.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            Cached object of the member that sent the message if found.
        """
        if isinstance(self.app, traits.CacheAware):
            return self.app.cache.get_member(self.guild_id, self.message.author.id)

        return None
Method resolution order
dataclass GuildMessageCreateEvent
That's this class!
abstract class MessageCreateEvent

Event that is fired when a message is created …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorusers.User

User object of the user that sent the message.

Returns

User
The user object of the user that sent the message.
property author_idSnowflake

ID of the author of the message this event concerns.

Returns

Snowflake
The ID of the author.
property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Optional[str]

Content of the message.

Returns

Optional[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent).
property embedsSequence[embeds_.Embed]

Sequence of embeds in the message.

Returns

Sequence[Embed]
The embeds in the message.
property guild_idSnowflake

ID of the guild that this event occurred in.

Returns

Snowflake
The ID of the guild that this event occurred in.
property is_botbool

Return True if the message is from a bot.

Returns

bool
True if from a bot, or False otherwise.
property is_humanbool

Return True if the message was created by a human.

Returns

bool
True if from a human user, or False otherwise.
property is_webhookbool

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
property memberOptional[guilds.Member]

Member object of the user that sent the message.

Returns

Optional[Member]
The member object of the user that sent the message or None if sent by a webhook.
property messagemessages.Message

Message that was sent in the event.

Returns

Message
The message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
property shardshard_.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def get_channel() -> Optional[TextableGuildChannel]: ...

Channel that the message was sent in, if known.

Returns

Optional[TextableGuildChannel]
The channel that the message was sent in, if known and cached, otherwise, None.
Expand source code
Browse git
def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
    """Channel that the message was sent in, if known.

    Returns
    -------
    typing.Optional[hikari.channels.TextableGuildChannel]
        The channel that the message was sent in, if known and cached,
        otherwise, `builtins.None`.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    channel = self.app.cache.get_guild_channel(self.channel_id)
    assert channel is None or isinstance(
        channel, channels.TextableGuildChannel
    ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
    return channel
def get_guild() -> Optional[guilds.GatewayGuild]: ...

Get the cached guild that this event occurred in, if known.

Note

This will require the GUILDS intent to be specified on start-up in order to be known.

Returns

Optional[GatewayGuild]
The guild that this event occurred in, if cached. Otherwise, None instead.
Expand source code
Browse git
def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
    """Get the cached guild that this event occurred in, if known.

    !!! note
        This will require the `GUILDS` intent to be specified on start-up
        in order to be known.

    Returns
    -------
    typing.Optional[hikari.guilds.GatewayGuild]
        The guild that this event occurred in, if cached. Otherwise,
        `builtins.None` instead.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    return self.app.cache.get_guild(self.guild_id)
def get_member() -> Optional[guilds.Member]: ...

Get the member that sent this message from the cache if available.

Returns

Optional[Member]
Cached object of the member that sent the message if found.
Expand source code
Browse git
def get_member(self) -> typing.Optional[guilds.Member]:
    """Get the member that sent this message from the cache if available.

    Returns
    -------
    typing.Optional[hikari.guilds.Member]
        Cached object of the member that sent the message if found.
    """
    if isinstance(self.app, traits.CacheAware):
        return self.app.cache.get_member(self.guild_id, self.message.author.id)

    return None
def bitmask() -> int: ...

Inherited from: MessageCreateEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageCreateEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass GuildMessageDeleteEvent

class GuildMessageDeleteEvent (
    *,
    app: traits.RESTAware,
    channel_id: snowflakes.Snowflake,
    guild_id: snowflakes.Snowflake,
    message_id: snowflakes.Snowflake,
    old_message: Optional[messages.Message],
    shard: shard_.GatewayShard,
): ...

Event that is triggered if a message is deleted in a guild.

Note

Due to Discord limitations, most message information is unavailable during deletion events.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class GuildMessageDeleteEvent.

Expand source code
Browse git
class GuildMessageDeleteEvent(MessageDeleteEvent):
    """Event that is triggered if a message is deleted in a guild.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

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

    channel_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageEvent>>

    guild_id: snowflakes.Snowflake = attr.field()
    """ID of the guild that this event occurred in."""

    message_id: snowflakes.Snowflake = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

    old_message: typing.Optional[messages.Message] = attr.field()
    # <<inherited docstring from MessageDeleteEvent>>

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

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Get the cached channel the message were sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel the messages were sent in, or `builtins.None` if not
            known/cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild this event corresponds to, if known.

        !!! note
            You will need `hikari.intents.Intents.GUILDS` enabled to receive this
            information.

        Returns
        -------
        hikari.guilds.GatewayGuild
            The gateway guild that this event corresponds to, if known and
            cached.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)
Method resolution order
dataclass GuildMessageDeleteEvent
That's this class!
abstract class MessageDeleteEvent

Special event that is triggered when a message gets deleted …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 channel_idsnowflakes.Snowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property guild_idsnowflakes.Snowflake

ID of the guild that this event occurred in.

property message_idsnowflakes.Snowflake

ID of the message that was deleted.

property old_messageOptional[messages.Message]

Object of the message that was deleted.

Will be None if the message was not found in the cache.

property shardshard_.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def get_channel() -> Optional[TextableGuildChannel]: ...

Get the cached channel the message were sent in, if known.

Returns

Optional[TextableGuildChannel]
The channel the messages were sent in, or None if not known/cached.
Expand source code
Browse git
def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
    """Get the cached channel the message were sent in, if known.

    Returns
    -------
    typing.Optional[hikari.channels.TextableGuildChannel]
        The channel the messages were sent in, or `builtins.None` if not
        known/cached.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    channel = self.app.cache.get_guild_channel(self.channel_id)
    assert channel is None or isinstance(
        channel, channels.TextableGuildChannel
    ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
    return channel
def get_guild() -> Optional[guilds.GatewayGuild]: ...

Get the cached guild this event corresponds to, if known.

Note

You will need GUILDS enabled to receive this information.

Returns

GatewayGuild
The gateway guild that this event corresponds to, if known and cached.
Expand source code
Browse git
def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
    """Get the cached guild this event corresponds to, if known.

    !!! note
        You will need `hikari.intents.Intents.GUILDS` enabled to receive this
        information.

    Returns
    -------
    hikari.guilds.GatewayGuild
        The gateway guild that this event corresponds to, if known and
        cached.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    return self.app.cache.get_guild(self.guild_id)
def bitmask() -> int: ...

Inherited from: MessageDeleteEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageDeleteEvent.dispatches

Sequence of the event classes this event is dispatched as.

dataclass GuildMessageUpdateEvent

class GuildMessageUpdateEvent (
    *,
    old_message: Optional[messages.PartialMessage],
    message: messages.PartialMessage,
    shard: shard_.GatewayShard,
): ...

Event that is fired when a message is updated in a guild.

Note

Less information will be available here than in the creation event due to Discord limitations.

This requires one of the following combinations of intents in order to be dispatched:

Method generated by attrs for class GuildMessageUpdateEvent.

Expand source code
Browse git
class GuildMessageUpdateEvent(MessageUpdateEvent):
    """Event that is fired when a message is updated in a guild.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    old_message: typing.Optional[messages.PartialMessage] = attr.field()
    """The old message object.

    This will be `builtins.None` if the message missing from the cache.
    """

    message: messages.PartialMessage = attr.field()
    # <<inherited docstring from MessageUpdateEvent>>

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

    @property
    def member(self) -> undefined.UndefinedNoneOr[guilds.Member]:
        """Member that sent the message if provided by the event.

        If the message is not in a guild, this will be `builtins.None`.

        This will also be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        return self.message.member

    def get_member(self) -> typing.Optional[guilds.Member]:
        """Get the member that sent this message from the cache if available.

        Returns
        -------
        typing.Optional[hikari.guilds.Member]
            Cached object of the member that sent the message if found.
        """
        if self.message.author is not undefined.UNDEFINED and isinstance(self.app, traits.CacheAware):
            return self.app.cache.get_member(self.guild_id, self.message.author.id)

        return None

    @property
    def guild_id(self) -> snowflakes.Snowflake:
        """ID of the guild that this event occurred in.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the guild that this event occurred in.
        """
        guild_id = self.message.guild_id
        # Always present on guild events
        assert isinstance(guild_id, snowflakes.Snowflake), f"expected guild_id, got {guild_id}"
        return guild_id

    def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
        """Channel that the message was sent in, if known.

        Returns
        -------
        typing.Optional[hikari.channels.TextableGuildChannel]
            The channel that the message was sent in, if known and cached,
            otherwise, `builtins.None`.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        channel = self.app.cache.get_guild_channel(self.channel_id)
        assert channel is None or isinstance(
            channel, channels.TextableGuildChannel
        ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
        return channel

    def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
        """Get the cached guild that this event occurred in, if known.

        !!! note
            This will require the `GUILDS` intent to be specified on start-up
            in order to be known.

        Returns
        -------
        typing.Optional[hikari.guilds.GatewayGuild]
            The guild that this event occurred in, if cached. Otherwise,
            `builtins.None` instead.
        """
        if not isinstance(self.app, traits.CacheAware):
            return None

        return self.app.cache.get_guild(self.guild_id)
Method resolution order
dataclass GuildMessageUpdateEvent
That's this class!
abstract class MessageUpdateEvent

Event that is fired when a message is updated …

abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorundefined.UndefinedOr[users.User]

User that sent the message.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property author_id : Union[SnowflakeUndefinedType]

ID of the author that triggered this event.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Union[strUndefinedTypeNone]

Content of the message.

Returns

UndefinedNoneOr[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent). If not part of the update, then this will be UNDEFINED instead.
property embedsundefined.UndefinedOr[Sequence[embeds_.Embed]]

Sequence of embeds in the message.

Returns

UndefinedOr[Sequence[Embed]]
The embeds in the message. If the embeds were not changed in this event, then this may instead be UNDEFINED.
property guild_idSnowflake

ID of the guild that this event occurred in.

Returns

Snowflake
The ID of the guild that this event occurred in.
property is_bot : Union[boolUndefinedType]

Return True if the message is from a bot.

Returns

Optional[bool]

True if from a bot, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this will return UNDEFINED instead.

property is_human : Union[boolUndefinedType]

Return True if the message was created by a human.

Returns

Optional[bool]

True if from a human user, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this may return UNDEFINED instead.

property is_webhook : Union[boolUndefinedType]

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
property memberundefined.UndefinedNoneOr[guilds.Member]

Member that sent the message if provided by the event.

If the message is not in a guild, this will be None.

This will also be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property messagemessages.PartialMessage

Partial message that was sent in the event.

Returns

PartialMessage
The partial message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
property old_messageOptional[messages.PartialMessage]

The old message object.

This will be None if the message missing from the cache.

property shardshard_.GatewayShard

Shard that received this event.

Returns

GatewayShard
The shard that triggered the event.
Methods
def get_channel() -> Optional[TextableGuildChannel]: ...

Channel that the message was sent in, if known.

Returns

Optional[TextableGuildChannel]
The channel that the message was sent in, if known and cached, otherwise, None.
Expand source code
Browse git
def get_channel(self) -> typing.Optional[channels.TextableGuildChannel]:
    """Channel that the message was sent in, if known.

    Returns
    -------
    typing.Optional[hikari.channels.TextableGuildChannel]
        The channel that the message was sent in, if known and cached,
        otherwise, `builtins.None`.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    channel = self.app.cache.get_guild_channel(self.channel_id)
    assert channel is None or isinstance(
        channel, channels.TextableGuildChannel
    ), f"Cached channel ID is not a TextableGuildChannel, but a {type(channel).__name__}!"
    return channel
def get_guild() -> Optional[guilds.GatewayGuild]: ...

Get the cached guild that this event occurred in, if known.

Note

This will require the GUILDS intent to be specified on start-up in order to be known.

Returns

Optional[GatewayGuild]
The guild that this event occurred in, if cached. Otherwise, None instead.
Expand source code
Browse git
def get_guild(self) -> typing.Optional[guilds.GatewayGuild]:
    """Get the cached guild that this event occurred in, if known.

    !!! note
        This will require the `GUILDS` intent to be specified on start-up
        in order to be known.

    Returns
    -------
    typing.Optional[hikari.guilds.GatewayGuild]
        The guild that this event occurred in, if cached. Otherwise,
        `builtins.None` instead.
    """
    if not isinstance(self.app, traits.CacheAware):
        return None

    return self.app.cache.get_guild(self.guild_id)
def get_member() -> Optional[guilds.Member]: ...

Get the member that sent this message from the cache if available.

Returns

Optional[Member]
Cached object of the member that sent the message if found.
Expand source code
Browse git
def get_member(self) -> typing.Optional[guilds.Member]:
    """Get the member that sent this message from the cache if available.

    Returns
    -------
    typing.Optional[hikari.guilds.Member]
        Cached object of the member that sent the message if found.
    """
    if self.message.author is not undefined.UNDEFINED and isinstance(self.app, traits.CacheAware):
        return self.app.cache.get_member(self.guild_id, self.message.author.id)

    return None
def bitmask() -> int: ...

Inherited from: MessageUpdateEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageUpdateEvent.dispatches

Sequence of the event classes this event is dispatched as.

class MessageCreateEvent

class MessageCreateEvent: ...

Event that is fired when a message is created.

This requires one of the following combinations of intents in order to be dispatched:

Expand source code
Browse git
class MessageCreateEvent(MessageEvent, abc.ABC):
    """Event that is fired when a message is created."""

    __slots__: typing.Sequence[str] = ()

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

    @property
    def author(self) -> users.User:
        """User that sent the message.

        Returns
        -------
        hikari.users.User
            The user that sent the message.
        """
        return self.message.author

    @property
    def author_id(self) -> snowflakes.Snowflake:
        """ID of the author of the message this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the author.
        """
        return self.author.id

    @property
    def channel_id(self) -> snowflakes.Snowflake:
        # <<inherited docstring from MessageEvent>>
        return self.message.channel_id

    @property
    def content(self) -> typing.Optional[str]:
        """Content of the message.

        Returns
        -------
        typing.Optional[builtins.str]
            The content of the message, if present. This may be `builtins.None`
            or an empty string (or any falsy value) if no content is present
            (e.g. if only an embed was sent).
        """
        return self.message.content

    @property
    def embeds(self) -> typing.Sequence[embeds_.Embed]:
        """Sequence of embeds in the message.

        Returns
        -------
        typing.Sequence[hikari.embeds.Embed]
            The embeds in the message.
        """
        return self.message.embeds

    @property
    def is_bot(self) -> bool:
        """Return `builtins.True` if the message is from a bot.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a bot, or `builtins.False` otherwise.
        """
        return self.message.author.is_bot

    @property
    def is_human(self) -> bool:
        """Return `builtins.True` if the message was created by a human.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a human user, or `builtins.False` otherwise.
        """
        # Not second-guessing some weird edge case will occur in the future with this,
        # so I am being safe rather than sorry.
        return not self.message.author.is_bot and self.message.webhook_id is None

    @property
    def is_webhook(self) -> bool:
        """Return `builtins.True` if the message was created by a webhook.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a webhook, or `builtins.False` otherwise.
        """
        return self.message.webhook_id is not None

    @property
    @abc.abstractmethod
    def message(self) -> messages.Message:
        """Message that was sent in the event.

        Returns
        -------
        hikari.messages.Message
            The message object that was sent with this event.
        """

    @property
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """
        return self.message.id
Subclasses
dataclass DMMessageCreateEvent

Event that is fired when a message is created within a DM …

dataclass GuildMessageCreateEvent

Event that is fired when a message is created within a guild …

Method resolution order
abstract class MessageCreateEvent
That's this class!
abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorusers.User

User that sent the message.

Returns

User
The user that sent the message.
property author_idSnowflake

ID of the author of the message this event concerns.

Returns

Snowflake
The ID of the author.
property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Optional[str]

Content of the message.

Returns

Optional[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent).
property embedsSequence[embeds_.Embed]

Sequence of embeds in the message.

Returns

Sequence[Embed]
The embeds in the message.
property is_botbool

Return True if the message is from a bot.

Returns

bool
True if from a bot, or False otherwise.
property is_humanbool

Return True if the message was created by a human.

Returns

bool
True if from a human user, or False otherwise.
property is_webhookbool

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
abstract property messagemessages.Message

Message that was sent in the event.

Returns

Message
The message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
abstract property shard : gateway_shard.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageEvent.dispatches

Sequence of the event classes this event is dispatched as.

class MessageDeleteEvent

class MessageDeleteEvent: ...

Special event that is triggered when a message gets deleted.

Note

Due to Discord limitations, most message information is unavailable during deletion events.

This requires one of the following combinations of intents in order to be dispatched:

Expand source code
Browse git
class MessageDeleteEvent(MessageEvent, abc.ABC):
    """Special event that is triggered when a message gets deleted.

    !!! note
        Due to Discord limitations, most message information is unavailable
        during deletion events.
    """

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that was deleted."""

    @property
    @abc.abstractmethod
    def old_message(self) -> typing.Optional[messages.Message]:
        """Object of the message that was deleted.

        Will be `None` if the message was not found in the cache.
        """
Subclasses
dataclass DMMessageDeleteEvent

Event that is triggered if a message is deleted in a DM …

dataclass GuildMessageDeleteEvent

Event that is triggered if a message is deleted in a guild …

Method resolution order
abstract class MessageDeleteEvent
That's this class!
abstract class MessageEvent

Any event that concerns manipulation of messages …

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 channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
abstract property message_idSnowflake

ID of the message that was deleted.

abstract property old_messageOptional[messages.Message]

Object of the message that was deleted.

Will be None if the message was not found in the cache.

abstract property shard : gateway_shard.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageEvent.dispatches

Sequence of the event classes this event is dispatched as.

class MessageEvent

class MessageEvent: ...

Any event that concerns manipulation of messages.

This requires one of the following combinations of intents in order to be dispatched:

Expand source code
Browse git
class MessageEvent(shard_events.ShardEvent, abc.ABC):
    """Any event that concerns manipulation of messages."""

    __slots__: typing.Sequence[str] = ()

    @property
    @abc.abstractmethod
    def channel_id(self) -> snowflakes.Snowflake:
        """ID of the channel that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the channel that this event concerns.
        """

    @property
    @abc.abstractmethod
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """
Subclasses
abstract class MessageCreateEvent

Event that is fired when a message is created …

abstract class MessageDeleteEvent

Special event that is triggered when a message gets deleted …

abstract class MessageUpdateEvent

Event that is fired when a message is updated …

Method resolution order
abstract class MessageEvent
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 channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
abstract property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
abstract property shard : gateway_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.

class MessageUpdateEvent

class MessageUpdateEvent: ...

Event that is fired when a message is updated.

Note

Less information will be available here than in the creation event due to Discord limitations.

This requires one of the following combinations of intents in order to be dispatched:

Expand source code
Browse git
class MessageUpdateEvent(MessageEvent, abc.ABC):
    """Event that is fired when a message is updated.

    !!! note
        Less information will be available here than in the creation event
        due to Discord limitations.
    """

    __slots__: typing.Sequence[str] = ()

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

    @property
    def author(self) -> undefined.UndefinedOr[users.User]:
        """User that sent the message.

        This will be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        return self.message.author

    @property
    def author_id(self) -> undefined.UndefinedOr[snowflakes.Snowflake]:
        """ID of the author that triggered this event.

        This will be `hikari.undefined.UNDEFINED` in some cases such as when Discord
        updates a message with an embed URL preview.
        """
        author = self.message.author
        return author.id if author is not undefined.UNDEFINED else undefined.UNDEFINED

    @property
    def channel_id(self) -> snowflakes.Snowflake:
        # <<inherited docstring from MessageEvent>>.
        return self.message.channel_id

    @property
    def content(self) -> undefined.UndefinedNoneOr[str]:
        """Content of the message.

        Returns
        -------
        hikari.undefined.UndefinedNoneOr[builtins.str]
            The content of the message, if present. This may be `builtins.None`
            or an empty string (or any falsy value) if no content is present
            (e.g. if only an embed was sent). If not part of the update, then
            this will be `hikari.undefined.UNDEFINED` instead.
        """
        return self.message.content

    @property
    def embeds(self) -> undefined.UndefinedOr[typing.Sequence[embeds_.Embed]]:
        """Sequence of embeds in the message.

        Returns
        -------
        hikari.undefined.UndefinedOr[typing.Sequence[hikari.embeds.Embed]]
            The embeds in the message. If the embeds were not changed in this
            event, then this may instead be `hikari.undefined.UNDEFINED`.
        """
        return self.message.embeds

    @property
    def is_bot(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message is from a bot.

        Returns
        -------
        typing.Optional[builtins.bool]
            `builtins.True` if from a bot, or `builtins.False` otherwise.

            If the author is not known, due to the update event being caused
            by Discord adding an embed preview to accompany a URL, then this
            will return `hikari.undefined.UNDEFINED` instead.
        """
        if (author := self.message.author) is not undefined.UNDEFINED:
            return author.is_bot

        return undefined.UNDEFINED

    @property
    def is_human(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message was created by a human.

        Returns
        -------
        typing.Optional[builtins.bool]
            `builtins.True` if from a human user, or `builtins.False` otherwise.

            If the author is not known, due to the update event being caused
            by Discord adding an embed preview to accompany a URL, then this
            may return `hikari.undefined.UNDEFINED` instead.
        """
        # Not second-guessing some weird edge case will occur in the future with this,
        # so I am being safe rather than sorry.
        if (webhook_id := self.message.webhook_id) is not undefined.UNDEFINED:
            return webhook_id is None

        if (author := self.message.author) is not undefined.UNDEFINED:
            return not author.is_bot

        return undefined.UNDEFINED

    @property
    def is_webhook(self) -> undefined.UndefinedOr[bool]:
        """Return `builtins.True` if the message was created by a webhook.

        Returns
        -------
        builtins.bool
            `builtins.True` if from a webhook, or `builtins.False` otherwise.
        """
        if (webhook_id := self.message.webhook_id) is not undefined.UNDEFINED:
            return webhook_id is not None

        return undefined.UNDEFINED

    @property
    @abc.abstractmethod
    def message(self) -> messages.PartialMessage:
        """Partial message that was sent in the event.

        Returns
        -------
        hikari.messages.PartialMessage
            The partial message object that was sent with this event.
        """

    @property
    def message_id(self) -> snowflakes.Snowflake:
        """ID of the message that this event concerns.

        Returns
        -------
        hikari.snowflakes.Snowflake
            The ID of the message that this event concerns.
        """
        return self.message.id
Subclasses
dataclass DMMessageUpdateEvent

Event that is fired when a message is updated in a DM …

dataclass GuildMessageUpdateEvent

Event that is fired when a message is updated in a guild …

Method resolution order
abstract class MessageUpdateEvent
That's this class!
abstract class MessageEvent

Any event that concerns manipulation of messages …

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 appRESTAware

App instance for this application.

Returns

RESTAware
The REST-aware app trait.
property authorundefined.UndefinedOr[users.User]

User that sent the message.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property author_id : Union[SnowflakeUndefinedType]

ID of the author that triggered this event.

This will be UNDEFINED in some cases such as when Discord updates a message with an embed URL preview.

property channel_idSnowflake

ID of the channel that this event concerns.

Returns

Snowflake
The ID of the channel that this event concerns.
property content : Union[strUndefinedTypeNone]

Content of the message.

Returns

UndefinedNoneOr[str]
The content of the message, if present. This may be None or an empty string (or any falsy value) if no content is present (e.g. if only an embed was sent). If not part of the update, then this will be UNDEFINED instead.
property embedsundefined.UndefinedOr[Sequence[embeds_.Embed]]

Sequence of embeds in the message.

Returns

UndefinedOr[Sequence[Embed]]
The embeds in the message. If the embeds were not changed in this event, then this may instead be UNDEFINED.
property is_bot : Union[boolUndefinedType]

Return True if the message is from a bot.

Returns

Optional[bool]

True if from a bot, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this will return UNDEFINED instead.

property is_human : Union[boolUndefinedType]

Return True if the message was created by a human.

Returns

Optional[bool]

True if from a human user, or False otherwise.

If the author is not known, due to the update event being caused by Discord adding an embed preview to accompany a URL, then this may return UNDEFINED instead.

property is_webhook : Union[boolUndefinedType]

Return True if the message was created by a webhook.

Returns

bool
True if from a webhook, or False otherwise.
abstract property messagemessages.PartialMessage

Partial message that was sent in the event.

Returns

PartialMessage
The partial message object that was sent with this event.
property message_idSnowflake

ID of the message that this event concerns.

Returns

Snowflake
The ID of the message that this event concerns.
abstract property shard : gateway_shard.GatewayShard

Shard that received this event.

Returns

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

Inherited from: MessageEvent.bitmask

Bitmask for this event.

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

Inherited from: MessageEvent.dispatches

Sequence of the event classes this event is dispatched as.