zaun_client/bots/events.rs
1//! What a member's client hears about its own interactions, addressed to it alone.
2
3use zaun_community_protocol::command::object::{Choice, Component, Message as Posted};
4use zaun_community_protocol::event::{EphemeralOp, FailReason};
5use zaun_community_protocol::ids::InteractionId;
6
7use crate::objects::{Channel, Community};
8
9/// A bot's ephemeral reply (`EPHEMERAL`): only this member sees it, nothing stores it, and it
10/// lives as long as the interaction (15 minutes). Key it by its message's `message_id`.
11#[derive(Debug, Clone)]
12pub struct EphemeralReply {
13 /// Where the interaction happened.
14 pub channel: Option<Channel>,
15 /// The interaction it answers.
16 pub interaction: InteractionId,
17 /// Created, updated or deleted.
18 pub op: EphemeralOp,
19 /// The message (absent when deleted).
20 pub message: Option<Box<Posted>>,
21}
22
23/// A bot asks this member to fill in a modal; submit it with
24/// [`Channel::submit_modal`](crate::Channel::submit_modal) and `interaction` as the modal id.
25#[derive(Debug, Clone)]
26pub struct ModalOpen {
27 /// Where the interaction happened.
28 pub channel: Option<Channel>,
29 /// The interaction that opened it.
30 pub interaction: InteractionId,
31 /// The modal's `custom_id`.
32 pub custom_id: String,
33 /// Its title.
34 pub title: String,
35 /// Labels and text displays.
36 pub components: Vec<Component>,
37}
38
39/// A bot's suggestions for the option this member is typing.
40#[derive(Debug, Clone)]
41pub struct Suggestions {
42 /// The community.
43 pub community: Community,
44 /// Where the interaction happened.
45 pub channel: Option<Channel>,
46 /// The autocomplete interaction.
47 pub interaction: InteractionId,
48 /// Up to 25.
49 pub choices: Vec<Choice>,
50}
51
52/// An interaction that got no answer (the bot timed out, failed or is not running).
53#[derive(Debug, Clone)]
54pub struct InteractionFailure {
55 /// Where the interaction happened.
56 pub channel: Option<Channel>,
57 /// The interaction.
58 pub interaction: InteractionId,
59 /// Why.
60 pub reason: FailReason,
61}