Skip to content

Internal

These are events dispatched by the client. This is intended as a reference so you know what data to expect for each event.

Example Usage

To listen to an event, use the listen decorator:

1
2
3
4
5
6
from interactions import listen
from interactions.api.events import ChannelCreate  # or any other event

@listen(ChannelCreate)
async def an_event_handler(event: ChannelCreate):
    print(f"Channel created with name: {event.channel.name}")

For more information, including other ways to listen to events, see the events guide.

Warning

While all of these events are documented, not all of them are used, currently.

AutocompleteCompletion

Bases: BaseEvent

Dispatched after the library ran any autocomplete callback.

Source code in interactions/api/events/internal.py
170
171
172
173
174
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class AutocompleteCompletion(BaseEvent):
    """Dispatched after the library ran any autocomplete callback."""

    ctx: "AutocompleteContext" = attrs.field(repr=False, metadata=docs("The autocomplete context"))

AutocompleteError

Bases: _Error

Dispatched when the library encounters an error in an autocomplete.

Source code in interactions/api/events/internal.py
215
216
217
218
219
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class AutocompleteError(_Error):
    """Dispatched when the library encounters an error in an autocomplete."""

    ctx: "AutocompleteContext" = attrs.field(repr=False, metadata=docs("The autocomplete context"))

ButtonPressed

Bases: Component

Dispatched when a user uses a Button.

Source code in interactions/api/events/internal.py
146
147
148
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class ButtonPressed(Component):
    """Dispatched when a user uses a Button."""

CallbackAdded

Bases: BaseEvent

Dispatched when a callback is added to the client.

Source code in interactions/api/events/internal.py
257
258
259
260
261
262
263
264
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class CallbackAdded(BaseEvent):
    """Dispatched when a callback is added to the client."""

    callback: "BaseCommand | Listener" = attrs.field(repr=False)
    """The callback that was added"""
    extension: "Extension | None" = attrs.field(repr=False, default=None)
    """The extension that the command was added from, if any"""

callback: BaseCommand | Listener = attrs.field(repr=False) class-attribute

The callback that was added

extension: Extension | None = attrs.field(repr=False, default=None) class-attribute

The extension that the command was added from, if any

CommandCompletion

Bases: BaseEvent

Dispatched after the library ran any command callback.

Source code in interactions/api/events/internal.py
156
157
158
159
160
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class CommandCompletion(BaseEvent):
    """Dispatched after the library ran any command callback."""

    ctx: "BaseContext" = attrs.field(repr=False, metadata=docs("The command context"))

CommandError

Bases: _Error

Dispatched when the library encounters an error in a command.

Source code in interactions/api/events/internal.py
201
202
203
204
205
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class CommandError(_Error):
    """Dispatched when the library encounters an error in a command."""

    ctx: "BaseContext" = attrs.field(repr=False, metadata=docs("The command context"))

Component

Bases: BaseEvent

Dispatched when a user uses a Component.

Source code in interactions/api/events/internal.py
139
140
141
142
143
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Component(BaseEvent):
    """Dispatched when a user uses a Component."""

    ctx: "ComponentContext" = attrs.field(repr=False, metadata=docs("The context of the interaction"))

ComponentCompletion

Bases: BaseEvent

Dispatched after the library ran any component callback.

Source code in interactions/api/events/internal.py
163
164
165
166
167
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ComponentCompletion(BaseEvent):
    """Dispatched after the library ran any component callback."""

    ctx: "ComponentContext" = attrs.field(repr=False, metadata=docs("The component context"))

ComponentError

Bases: _Error

Dispatched when the library encounters an error in a component.

Source code in interactions/api/events/internal.py
208
209
210
211
212
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ComponentError(_Error):
    """Dispatched when the library encounters an error in a component."""

    ctx: "ComponentContext" = attrs.field(repr=False, metadata=docs("The component context"))

Connect

Bases: BaseEvent

The bot is now connected to the discord Gateway.

Source code in interactions/api/events/internal.py
80
81
82
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Connect(BaseEvent):
    """The bot is now connected to the discord Gateway."""

Disconnect

Bases: BaseEvent

The bot has just disconnected.

Source code in interactions/api/events/internal.py
90
91
92
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Disconnect(BaseEvent):
    """The bot has just disconnected."""

Error

Bases: _Error

Dispatched when the library encounters an error.

Source code in interactions/api/events/internal.py
191
192
193
194
195
196
197
198
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class Error(_Error):
    """Dispatched when the library encounters an error."""

    source: str = attrs.field(repr=False, metadata=docs("The source of the error"))
    ctx: Optional["BaseContext"] = attrs.field(
        repr=False, default=None, metadata=docs("The Context, if one was active")
    )

ExtensionCommandParse

Bases: ExtensionLoad

Dispatched when an extension is parsed for commands.

Source code in interactions/api/events/internal.py
249
250
251
252
253
254
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ExtensionCommandParse(ExtensionLoad):
    """Dispatched when an extension is parsed for commands."""

    callables: list[tuple[str, typing.Callable]] = attrs.field(repr=False, default=None)
    """The callables that were parsed for commands"""

callables: list[tuple[str, typing.Callable]] = attrs.field(repr=False, default=None) class-attribute

The callables that were parsed for commands

ExtensionLoad

Bases: BaseEvent

Dispatched when an extension is loaded.

Source code in interactions/api/events/internal.py
229
230
231
232
233
234
235
236
237
238
239
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ExtensionLoad(BaseEvent):
    """Dispatched when an extension is loaded."""

    extension: "Extension" = attrs.field(repr=False)
    """The extension in question"""

    @property
    def metadata(self) -> "Type[Extension.Metadata] | None":
        """The metadata of the extension, if it has any."""
        return self.extension.Metadata or None

extension: Extension = attrs.field(repr=False) class-attribute

The extension in question

metadata: Type[Extension.Metadata] | None property

The metadata of the extension, if it has any.

ExtensionUnload

Bases: ExtensionLoad

Dispatched when an extension is unloaded.

Source code in interactions/api/events/internal.py
242
243
244
245
246
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ExtensionUnload(ExtensionLoad):
    """Dispatched when an extension is unloaded."""

    ...

Login

Bases: BaseEvent

The bot has just logged in.

Source code in interactions/api/events/internal.py
75
76
77
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Login(BaseEvent):
    """The bot has just logged in."""

ModalCompletion

Bases: BaseEvent

Dispatched after the library ran any modal callback.

Source code in interactions/api/events/internal.py
177
178
179
180
181
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ModalCompletion(BaseEvent):
    """Dispatched after the library ran any modal callback."""

    ctx: "ModalContext" = attrs.field(repr=False, metadata=docs("The modal context"))

ModalError

Bases: _Error

Dispatched when the library encounters an error in a modal.

Source code in interactions/api/events/internal.py
222
223
224
225
226
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
class ModalError(_Error):
    """Dispatched when the library encounters an error in a modal."""

    ctx: "ModalContext" = attrs.field(repr=False, metadata=docs("The modal context"))

Ready

Bases: BaseEvent

The client is now ready.

Note

Don't use this event for things that must only happen once, on startup, as this event may be called multiple times. Instead, use the Startup event

Source code in interactions/api/events/internal.py
120
121
122
123
124
125
126
127
128
129
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Ready(BaseEvent):
    """
    The client is now ready.

    !!! note
        Don't use this event for things that must only happen once, on startup, as this event may be called multiple times.
        Instead, use the `Startup` event

    """

Resume

Bases: BaseEvent

The bot has resumed its connection to the discord Gateway.

Source code in interactions/api/events/internal.py
85
86
87
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Resume(BaseEvent):
    """The bot has resumed its connection to the discord Gateway."""

Select

Bases: Component

Dispatched when a user uses a Select.

Source code in interactions/api/events/internal.py
151
152
153
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Select(Component):
    """Dispatched when a user uses a Select."""

ShardConnect

Bases: Connect

A shard just connected to the discord Gateway.

Source code in interactions/api/events/internal.py
95
96
97
98
99
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class ShardConnect(Connect):
    """A shard just connected to the discord Gateway."""

    shard_id: int = attrs.field(repr=False, metadata=docs("The ID of the shard"))

ShardDisconnect

Bases: Disconnect

A shard just disconnected.

Source code in interactions/api/events/internal.py
102
103
104
105
106
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class ShardDisconnect(Disconnect):
    """A shard just disconnected."""

    shard_id: int = attrs.field(repr=False, metadata=docs("The ID of the shard"))

Startup

Bases: BaseEvent

The client is now ready for the first time.

Use this for tasks you want to do upon login, instead of ready, as this will only be called once.

Source code in interactions/api/events/internal.py
109
110
111
112
113
114
115
116
117
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class Startup(BaseEvent):
    """
    The client is now ready for the first time.

    Use this for tasks you want to do upon login, instead of ready, as
    this will only be called once.

    """

WebsocketReady

Bases: RawGatewayEvent

The gateway has reported that it is ready.

Source code in interactions/api/events/internal.py
132
133
134
135
136
@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class WebsocketReady(RawGatewayEvent):
    """The gateway has reported that it is ready."""

    data: dict = attrs.field(repr=False, metadata=docs("The data from the ready event"))