#[non_exhaustive]pub struct Activity {Show 18 fields
pub name: CompactString,
pub kind: ActivityType,
pub url: Option<CompactString>,
pub created_at: Option<Timestamp>,
pub timestamps: Option<ActivityTimestamps>,
pub application_id: Option<ApplicationId>,
pub status_display_type: Option<StatusDisplayType>,
pub details: Option<CompactString>,
pub details_url: Option<CompactString>,
pub state: Option<CompactString>,
pub state_url: Option<CompactString>,
pub emoji: Option<ActivityEmoji>,
pub party: Option<ActivityParty>,
pub assets: Option<Box<ActivityAssets>>,
pub secrets: Option<Box<ActivitySecrets>>,
pub instance: bool,
pub flags: ActivityFlags,
pub buttons: Vec<CompactString>,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: CompactStringThe activity’s name.
kind: ActivityTypeThe kind of activity.
url: Option<CompactString>The stream URL (Streaming; Twitch and YouTube only).
created_at: Option<Timestamp>When the activity was added to the user’s session.
timestamps: Option<ActivityTimestamps>When the game started and/or ends.
application_id: Option<ApplicationId>The game’s application.
status_display_type: Option<StatusDisplayType>Which field the member list shows as status text.
details: Option<CompactString>What the player is doing.
details_url: Option<CompactString>The URL linked from the details text.
state: Option<CompactString>The party status, or the text of a custom status.
state_url: Option<CompactString>The URL linked from the state text.
emoji: Option<ActivityEmoji>The emoji of a custom status.
party: Option<ActivityParty>The player’s party.
assets: Option<Box<ActivityAssets>>The images and their hover texts.
secrets: Option<Box<ActivitySecrets>>The Rich Presence secrets for joining and spectating.
instance: boolWhether the activity is an instanced game session.
flags: ActivityFlagsWhat the activity supports.
The labels of the custom buttons (max 2; bots cannot see the URLs).
Implementations§
Source§impl Activity
impl Activity
Sourcepub fn new(kind: ActivityType, name: impl Into<CompactString>) -> Self
pub fn new(kind: ActivityType, name: impl Into<CompactString>) -> Self
Sourcepub fn playing(name: impl Into<CompactString>) -> Self
pub fn playing(name: impl Into<CompactString>) -> Self
“Playing {name}”.
discord.js counterpart: ActivitiesOptions with type: ActivityType.Playing.
§Examples
use djs_model::gateway::{Activity, ActivityType};
let activity = Activity::playing("with Rust");
assert_eq!((activity.kind, activity.name.as_str()), (ActivityType::Playing, "with Rust"));Sourcepub fn streaming(
name: impl Into<CompactString>,
url: impl Into<CompactString>,
) -> Self
pub fn streaming( name: impl Into<CompactString>, url: impl Into<CompactString>, ) -> Self
“Streaming {name}”, linking to url. Discord only accepts https://twitch.tv/ and
https://youtube.com/ URLs.
discord.js counterpart: ActivitiesOptions with type: ActivityType.Streaming.
§Examples
use djs_model::gateway::Activity;
let activity = Activity::streaming("Rust live", "https://twitch.tv/example");
assert_eq!(
serde_json::to_string(&activity).unwrap(),
r#"{"name":"Rust live","type":1,"url":"https://twitch.tv/example"}"#
);Sourcepub fn listening(name: impl Into<CompactString>) -> Self
pub fn listening(name: impl Into<CompactString>) -> Self
“Listening to {name}”.
discord.js counterpart: ActivitiesOptions with type: ActivityType.Listening.
Sourcepub fn watching(name: impl Into<CompactString>) -> Self
pub fn watching(name: impl Into<CompactString>) -> Self
“Watching {name}”.
discord.js counterpart: ActivitiesOptions with type: ActivityType.Watching.
Sourcepub fn competing(name: impl Into<CompactString>) -> Self
pub fn competing(name: impl Into<CompactString>) -> Self
“Competing in {name}”.
discord.js counterpart: ActivitiesOptions with type: ActivityType.Competing.
Sourcepub fn custom(text: impl Into<CompactString>) -> Self
pub fn custom(text: impl Into<CompactString>) -> Self
A custom status showing text (stored in state; the name is
"Custom Status", as Discord’s clients send).
discord.js counterpart: ActivitiesOptions with type: ActivityType.Custom.
§Examples
use djs_model::gateway::Activity;
let activity = Activity::custom("Fixing bugs");
assert_eq!(activity.state.as_deref(), Some("Fixing bugs"));