Skip to main content

ResponseExt

Trait ResponseExt 

Source
pub trait ResponseExt {
    // Required method
    fn json(&self) -> Value;

    // Provided methods
    fn response_type(&self) -> u8 { ... }
    fn text(&self) -> Option<String> { ... }
    fn is_ephemeral(&self) -> bool { ... }
    fn components(&self) -> Vec<Value> { ... }
    fn button(&self, label: &str) -> Option<Value> { ... }
    fn custom_id(&self, label: &str) -> Option<String> { ... }
    fn embeds(&self) -> Vec<Value> { ... }
    fn choices(&self) -> Vec<Value> { ... }
}
Available on crate feature testing only.
Expand description

Reading an InteractionResponse in assertions, through its JSON (what Discord receives). Components are found anywhere in the message: in action rows, sections and containers.

Required Methods§

Source

fn json(&self) -> Value

The response as Discord receives it

Provided Methods§

Source

fn response_type(&self) -> u8

The response type: 4 message, 5 deferred message, 6 deferred update, 7 update, 8 autocomplete, 9 modal

Source

fn text(&self) -> Option<String>

The message’s content, else its text displays’ content joined with newlines (Components V2); None without either

Source

fn is_ephemeral(&self) -> bool

Whether the message (or deferral) is only shown to the invoking user

Source

fn components(&self) -> Vec<Value>

Every component, depth first

Source

fn button(&self, label: &str) -> Option<Value>

The first component labeled label (a button, mostly)

Source

fn custom_id(&self, label: &str) -> Option<String>

The custom_id of the component labeled label

Source

fn embeds(&self) -> Vec<Value>

The message’s embeds

Source

fn choices(&self) -> Vec<Value>

An autocomplete response’s choices

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ResponseExt for Value

A response as JSON, like one read back from an Adapter over HTTP

Source§

fn json(&self) -> Value

Implementors§