gaato/discord/framework does not have a README file

InteractionContextError

pub(all) suberror InteractionContextError {
MissingInvoker
MissingGuildMemberUser
MissingGuildId
MissingComponentMessage
} derive(
Debug
)

A malformed interaction that cannot satisfy the guarantees exposed by a typed handler context.

ResponseGateError

An error raised when an interaction callback cannot be accepted.

AutocompleteCtx

Context handed to an autocomplete handler.

AutocompleteCtx::suggest

Send autocomplete suggestions. Choices beyond the first 25 are truncated.

CapturedResponse

A callback plus any multipart files captured by an in-memory gate.

CommandCtx

Context handed to a slash / context-menu command handler.

CommandCtx::defer_response

async fn CommandCtx::defer_response(self : CommandCtx, ephemeral? : Bool) -> Unit

Acknowledge now and reply later via edit_response / followup.

CommandCtx::delete_followup

Delete a followup message for this command interaction.

CommandCtx::delete_response

async fn CommandCtx::delete_response(self : CommandCtx) -> Unit

Delete the original response to this command interaction.

CommandCtx::edit_followup

Edit a followup message for this command interaction.

CommandCtx::edit_response

Edit the original response (typically after defer).

CommandCtx::followup

Send a followup message after the initial response.

CommandCtx::get_followup

Fetch a followup message for this command interaction.

CommandCtx::guild_scope

fn CommandCtx::guild_scope(self : CommandCtx) -> GuildInvocation?

The validated guild invocation, or None when invoked in a DM.

CommandCtx::model

Decode the submitted options into a typed CommandModel.

CommandCtx::original_response

async fn CommandCtx::original_response(self : CommandCtx) ->
Message

Fetch the original response to this command interaction.

CommandCtx::respond

async fn CommandCtx::respond(self : CommandCtx, content? : String, embeds? : Array[
Embed
], components? : Array[
Component
], files? : Array[
FileUpload
], allowed_mentions? :
AllowedMentions
, ephemeral? : Bool) -> Unit

Send the initial "channel message with source" response.

CommandCtx::scope

Whether the command was invoked in a guild or a DM.

CommandCtx::show_modal

async fn CommandCtx::show_modal(self : CommandCtx, custom_id~ : String, title~ : String, components~ : Array[
Component
]) -> Unit

Display a modal as the initial command response.

CommandCtx::target_message

The resolved target of a MESSAGE context-menu command, or None when this is not a message command or its target is unavailable.

CommandCtx::target_user

fn CommandCtx::target_user(self : CommandCtx) -> TargetUser?

The resolved target of a USER context-menu command, or None when this is not a user command or its target is unavailable.

CommandCtx::user

The invoking user.

ComponentCtx

Context handed to a message-component (button / select) handler.

ComponentCtx::defer_response

async fn ComponentCtx::defer_response(self : ComponentCtx, ephemeral? : Bool) -> Unit

Acknowledge now and send a message later through webhook methods.

ComponentCtx::defer_update

async fn ComponentCtx::defer_update(self : ComponentCtx) -> Unit

Acknowledge without any visible change (edit later if needed).

ComponentCtx::delete_followup

Delete a followup message for this component interaction.

ComponentCtx::delete_response

async fn ComponentCtx::delete_response(self : ComponentCtx) -> Unit

Delete the original response to this component interaction.

ComponentCtx::edit_followup

Edit a followup message for this component interaction.

ComponentCtx::edit_response

Edit the original interaction response after deferring.

ComponentCtx::followup

Send a component-interaction followup message.

ComponentCtx::get_followup

Fetch a followup message for this component interaction.

ComponentCtx::guild_scope

fn ComponentCtx::guild_scope(self : ComponentCtx) -> GuildInvocation?

The validated guild invocation, or None when invoked in a DM.

ComponentCtx::message

The message to which the component was attached.

ComponentCtx::original_response

async fn ComponentCtx::original_response(self : ComponentCtx) ->
Message

Fetch the original response to this component interaction.

ComponentCtx::respond

async fn ComponentCtx::respond(self : ComponentCtx, content? : String, embeds? : Array[
Embed
], components? : Array[
Component
], files? : Array[
FileUpload
], allowed_mentions? :
AllowedMentions
, ephemeral? : Bool) -> Unit

Send a new "channel message with source" response.

ComponentCtx::scope

Whether the component was invoked in a guild or a DM.

ComponentCtx::show_modal

async fn ComponentCtx::show_modal(self : ComponentCtx, custom_id~ : String, title~ : String, components~ : Array[
Component
]) -> Unit

Display a modal as the initial component response.

ComponentCtx::update_message

async fn ComponentCtx::update_message(self : ComponentCtx, content? : String, embeds? : Array[
Embed
], components? : Array[
Component
], allowed_mentions? :
AllowedMentions
) -> Unit

Edit the message the component is attached to.

ComponentCtx::user

The invoking user.

Framework

pub struct Framework {
// private fields
}

Routes incoming interactions to declared command / component / modal handlers, and can register the declared commands with Discord.

Registration methods return self for chaining. Feed every InteractionCreate gateway event to process.

Framework::Framework

Create an empty interaction router bound to a REST client and application id. Most bots configure routes through @app.App and let an executor call App::attach instead of registering here directly.

Framework::autocomplete

fn Framework::autocomplete(self : Framework, command_name : String, handler : async (AutocompleteCtx) -> Unit) -> Framework

Register an autocomplete handler for a command name.

Framework::command

fn Framework::command(self : Framework, spec :
CommandSpec
, handler : async (CommandCtx) -> Unit) -> Framework

Register a command: spec describes it to Discord, handler runs when it is invoked. Routing is by command type and top-level command name; subcommand routing happens inside the handler via ctx.options.path().

Framework::command_specs

fn Framework::command_specs(self : Framework) -> Json

The registration payload for every declared command, as sent to the bulk-overwrite endpoints.

Framework::component

fn Framework::component(self : Framework, prefix : String, handler : async (ComponentCtx) -> Unit) -> Framework

Register a component handler for custom ids starting with prefix. Longer prefixes win; equally long prefixes retain registration order. Exact-id waiters take precedence over all registered handlers.

Framework::modal

fn Framework::modal(self : Framework, prefix : String, handler : async (ModalCtx) -> Unit) -> Framework

Register a modal-submit handler for custom ids starting with prefix. Longer prefixes win; equally long prefixes retain registration order.

Framework::on_error

fn Framework::on_error(self : Framework, hook : async (String, Error) -> Unit) -> Framework

Install an error hook. When set, handler errors are passed to it (with a kind:name label) instead of propagating out of process.

Framework::process

async fn Framework::process(self : Framework, interaction :
Interaction
) -> Bool

Route one interaction. Returns true when a handler (or waiter) consumed it, false when nothing matched. Handler errors propagate unless an on_error hook is installed.

Framework::process_with

async fn Framework::process_with(self : Framework, interaction :
Interaction
, gate~ : ResponseGate) -> Bool

Route one interaction through a caller-provided initial-response gate.

Framework::sync_global

Replace all global commands with the declared ones.

Framework::sync_guild

Replace all commands of one guild with the declared ones. Guild commands update instantly, which makes this the right call during development.

Framework::wait_for_component

async fn Framework::wait_for_component(self : Framework, custom_id~ : String, timeout_ms? : Int) -> ComponentCtx?

Wait for the next component interaction whose custom id matches exactly. Returns None on timeout. Waiters win over registered component handlers, which makes multi-step flows (confirm buttons, pagination) straightforward inside one handler.

GuildInvocation

Proof that an interaction was invoked in a guild: the guild id and the invoking member, both validated when the context was built.

GuildInvocation::user

The user who invoked this interaction.

InvocationScope

pub(all) enum InvocationScope {
Guild(GuildInvocation)
Dm(
User
)
} derive(
Debug
)

The context in which an interaction was invoked.

ModalCtx

Context handed to a modal-submit handler.

ModalCtx::defer_response

async fn ModalCtx::defer_response(self : ModalCtx, ephemeral? : Bool) -> Unit

Acknowledge now and reply later via a followup.

ModalCtx::delete_followup

async fn ModalCtx::delete_followup(self : ModalCtx, message_id :
Id
[
MessageMarker
]) -> Unit

Delete a followup message for this modal interaction.

ModalCtx::delete_response

async fn ModalCtx::delete_response(self : ModalCtx) -> Unit

Delete the original response to this modal interaction.

ModalCtx::edit_followup

Edit a followup message for this modal interaction.

ModalCtx::edit_response

Edit the original modal interaction response after deferring.

ModalCtx::followup

Send a modal-interaction followup message.

ModalCtx::get_followup

Fetch a followup message for this modal interaction.

ModalCtx::guild_scope

fn ModalCtx::guild_scope(self : ModalCtx) -> GuildInvocation?

The validated guild invocation, or None when invoked in a DM.

ModalCtx::origin

fn ModalCtx::origin(self : ModalCtx) -> ModalOrigin

Whether the modal was opened from a component or from a command.

ModalCtx::original_response

async fn ModalCtx::original_response(self : ModalCtx) ->
Message

Fetch the original response to this modal interaction.

ModalCtx::respond

async fn ModalCtx::respond(self : ModalCtx, content? : String, embeds? : Array[
Embed
], components? : Array[
Component
], files? : Array[
FileUpload
], allowed_mentions? :
AllowedMentions
, ephemeral? : Bool) -> Unit

Send a "channel message with source" response to the modal.

ModalCtx::scope

fn ModalCtx::scope(self : ModalCtx) -> InvocationScope

Whether the modal was submitted in a guild or a DM.

ModalCtx::text_value

fn ModalCtx::text_value(self : ModalCtx, custom_id : String) -> String?

The submitted value of the text input with the given custom id.

ModalCtx::user

The invoking user.

ModalOrigin

pub(all) enum ModalOrigin {
FromComponent(
Message
)
FromCommand
} derive(
Debug
)

The interaction that opened a submitted modal.

ResponseCapture

pub struct ResponseCapture {
// private fields
}

The receiving side of a capture gate.

ResponseCapture::get

Wait for and remove the captured callback.

ResponseCapture::try_get

fn ResponseCapture::try_get(self : ResponseCapture) -> CapturedResponse? raise

Remove the captured callback without waiting, if one is available.

ResponseGate

pub struct ResponseGate {
// private fields
}

A single-use interaction callback gate.

ResponseGate::ResponseGate

Construct a gate around an injected callback sink.

ResponseGate::capture

Construct an in-memory gate and a receiver for the first callback value.

ResponseGate::responded

fn ResponseGate::responded(self : ResponseGate) -> Bool

Whether this gate has attempted its single callback delivery.

ResponseGate::rest

Construct a gate that delivers its callback through Discord's REST API.

ResponseGate::send

Validate and deliver the one allowed initial interaction callback.

TargetUser

pub(all) struct TargetUser {
user :
User

member :
GuildMember
?
}

The resolved target of a USER context-menu command.