#[non_exhaustive]pub struct UpdatePresence {
pub since: Option<Timestamp>,
pub activities: Vec<Activity>,
pub status: Status,
pub afk: bool,
}Expand description
Update Presence (opcode 3): sets the bot’s status and activities (5 updates per 20 seconds).
discord.js counterpart: ClientUser#setPresence.
§Examples
use djs_model::gateway::{Activity, ActivityType, Status, payload::UpdatePresence};
let presence = UpdatePresence::new(Status::Online, [Activity::new(ActivityType::Watching, "you")]);
assert_eq!(
serde_json::to_string(&presence).unwrap(),
r#"{"since":null,"activities":[{"name":"you","type":3}],"status":"online","afk":false}"#
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.since: Option<Timestamp>When the bot went idle (sent as Unix milliseconds, D-075), None if not idle.
activities: Vec<Activity>The activities (bots can set the name, state, type and URL).
status: StatusThe status.
afk: boolWhether the bot is AFK.
Implementations§
Source§impl UpdatePresence
impl UpdatePresence
Sourcepub fn new(
status: Status,
activities: impl IntoIterator<Item = Activity>,
) -> Self
pub fn new( status: Status, activities: impl IntoIterator<Item = Activity>, ) -> Self
Sets the status and activities (not idle, not AFK).
discord.js counterpart: ClientUser#setPresence.
Trait Implementations§
Source§impl Clone for UpdatePresence
impl Clone for UpdatePresence
Source§impl Debug for UpdatePresence
impl Debug for UpdatePresence
impl Eq for UpdatePresence
Source§impl GatewayCommand for UpdatePresence
impl GatewayCommand for UpdatePresence
Source§impl PartialEq for UpdatePresence
impl PartialEq for UpdatePresence
Source§impl Serialize for UpdatePresence
impl Serialize for UpdatePresence
impl StructuralPartialEq for UpdatePresence
Auto Trait Implementations§
impl Freeze for UpdatePresence
impl RefUnwindSafe for UpdatePresence
impl Send for UpdatePresence
impl Sync for UpdatePresence
impl Unpin for UpdatePresence
impl UnsafeUnpin for UpdatePresence
impl UnwindSafe for UpdatePresence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more