pub struct Context {
pub id: Id,
pub bot_id: Id,
pub channel_id: Id,
pub member: Member,
pub app_permissions: u64,
pub locale: Option<String>,
pub message: Option<Message>,
pub created_at: u64,
}Expand description
The interaction being handled, without its data (handlers get the data separately).
The first answer must be one of reply,
reply_ephemeral, respond,
defer, defer_update,
update_message or show_modal, within 3 s.
After it, use followup and edit_original for
15 minutes.
Fields§
§id: IdThe interaction id.
bot_id: IdThe bot’s id in this community.
channel_id: IdThe channel it happened in.
member: MemberWho triggered it.
app_permissions: u64The bot’s effective permissions in the channel.
locale: Option<String>The invoker’s locale (BCP 47), if their client sent one.
message: Option<Message>For component interactions: the message holding the component.
created_at: u64When the host received it (ms).
Implementations§
Source§impl Context
impl Context
Sourcepub fn split(i: Interaction) -> (Self, InteractionData)
pub fn split(i: Interaction) -> (Self, InteractionData)
Splits an interaction into its context and data.
Sourcepub fn delete_original(&self) -> Result<(), HostError>
pub fn delete_original(&self) -> Result<(), HostError>
Sourcepub fn dm(
&self,
member_id: &str,
reply: impl Into<Reply>,
) -> Result<(Id, Id), HostError>
pub fn dm( &self, member_id: &str, reply: impl Into<Reply>, ) -> Result<(Id, Id), HostError>
Sends a direct message to a member (capability dms), for example the invoker:
ctx.dm(&ctx.member.member_id, "details"). Returns the DM’s channel id and the
message id.
§Errors
The host’s refusal (FORBIDDEN with reason dms_closed when the member does not take
DMs from bots).
Source§impl Context
Presence shortcuts, for handlers that already hold a Context.
impl Context
Presence shortcuts, for handlers that already hold a Context.
Sourcepub fn set_presence(
&self,
status: Status,
activity: impl Into<Option<Activity>>,
)
pub fn set_presence( &self, status: Status, activity: impl Into<Option<Activity>>, )
Sets the bot’s status and activity (crate::presence::set).