#[non_exhaustive]pub enum InteractionResponse {
Pong,
ChannelMessageWithSource(Box<MessageCallbackData>),
DeferredChannelMessageWithSource(DeferredCallbackData),
DeferredUpdateMessage,
UpdateMessage(Box<MessageCallbackData>),
AutocompleteResult(AutocompleteCallbackData),
Modal(Box<ModalCallbackData>),
PremiumRequired,
LaunchActivity,
Unknown(InteractionCallbackType),
}Expand description
An interaction response:
how the app answers an Interaction, within 3 seconds, by
POST /interactions/{id}/{token}/callback or as the body of the HTTP endpoint’s reply.
Written as {"type": …, "data": …}; the variant decides the type.
discord.js counterpart: what reply, deferReply, update, deferUpdate, respond,
showModal and launchActivity send.
§Examples
use djs_model::interaction::{InteractionResponse, MessageCallbackData};
let reply = MessageCallbackData::from("Only you can see this.").ephemeral();
let response = InteractionResponse::ChannelMessageWithSource(Box::new(reply));
assert_eq!(
serde_json::to_string(&response).unwrap(),
r#"{"type":4,"data":{"content":"Only you can see this.","flags":64}}"#
);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pong
Acknowledges a Ping.
ChannelMessageWithSource(Box<MessageCallbackData>)
Responds with a message.
discord.js counterpart: reply.
DeferredChannelMessageWithSource(DeferredCallbackData)
Acknowledges the interaction and shows “thinking…”; the response message is sent later by editing the original response.
discord.js counterpart: deferReply.
DeferredUpdateMessage
Acknowledges a component or modal-submit interaction without a loading state; the message is edited later.
discord.js counterpart: deferUpdate.
UpdateMessage(Box<MessageCallbackData>)
Edits the message the component is on (component and modal-submit interactions).
discord.js counterpart: update.
AutocompleteResult(AutocompleteCallbackData)
Suggests choices to an Autocomplete
interaction.
discord.js counterpart: AutocompleteInteraction#respond.
Modal(Box<ModalCallbackData>)
Opens a modal (not available for modal-submit and ping interactions).
discord.js counterpart: showModal.
PremiumRequired
Deprecated: responds with an upgrade button (monetized apps); use a premium
Button instead.
LaunchActivity
Launches the app’s Activity (apps with Activities).
discord.js counterpart: launchActivity.
Unknown(InteractionCallbackType)
A response type this version does not know (only produced when decoding); its data is not kept.
Implementations§
Source§impl InteractionResponse
impl InteractionResponse
Sourcepub fn files(&self) -> &[FileUpload]
pub fn files(&self) -> &[FileUpload]
Returns the files to upload with the response (those of its message data); empty for responses without a message.
discord.js counterpart: the files of InteractionReplyOptions.
Sourcepub const fn kind(&self) -> InteractionCallbackType
pub const fn kind(&self) -> InteractionCallbackType
Returns the response type.
discord.js counterpart: InteractionResponseType (discord-api-types).