Struct EventContext
zaun_bot::EventContext · Struct
pub struct EventContext { … }What an event handler can do: send, reply, react, delete and send direct messages. Every call is an ordinary command on the bot’s member, checked by the host.
Fields
Section titled “Fields”me: Option<Ready>
Section titled “me: Option<Ready>”Who and where the bot is, once on_ready has run (always, for every later event).
Methods
Section titled “Methods”pub fn send<impl Into<Reply>>(&self, channel_id: &str, reply: impl Into<Reply>) -> Result<Id, HostError>Sends a message to a channel. Returns its id.
Errors
Section titled “Errors”The host’s refusal.
reply_to
Section titled “reply_to”pub fn reply_to<impl Into<Reply>>(&self, message: &Message, reply: impl Into<Reply>) -> Result<Id, HostError>Replies to a message, in its channel.
Errors
Section titled “Errors”The host’s refusal.
pub fn react(&self, message: &Message, emoji: &str) -> Result<(), HostError>Adds a reaction.
Errors
Section titled “Errors”The host’s refusal.
delete_message
Section titled “delete_message”pub fn delete_message(&self, message: &Message) -> Result<(), HostError>Deletes a message (the bot’s own, or any with MANAGE_MESSAGES).
Errors
Section titled “Errors”The host’s refusal.
pub fn dm<impl Into<Reply>>(&self, member_id: &str, reply: impl Into<Reply>) -> Result<(Id, Id), HostError>Sends a direct message to a member (capability dms). Returns the DM’s channel id and
the message id. FORBIDDEN with reason dms_closed when the member does not take DMs
from bots or closed this one.
Errors
Section titled “Errors”The host’s refusal.
pub fn is_me(&self, member_id: &str) -> boolWhether member_id is the bot itself (to ignore its own messages).
mentions_me
Section titled “mentions_me”pub fn mentions_me(&self, message: &Message) -> boolWhether message mentions the bot: by its member id, by @everyone, or by one of its
roles. Only when the message names roles does it ask the host for the bot’s own roles
(community::get_member); a refusal there counts as not mentioned.
Trait implementations
Section titled “Trait implementations”Clone, Debug, Default