Added documentation for Activity
This commit is contained in:
parent
8b9ee6fb3e
commit
56c90e454b
1 changed files with 33 additions and 1 deletions
|
|
@ -4,57 +4,74 @@ use crate::models::activity_data::{
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Test Doc
|
/// Represents a Discord Activity object to be send to Discord application.
|
||||||
|
/// See https://discord.com/developers/docs/game-sdk/activities#data-models for more information.
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug)]
|
||||||
pub struct Activity {
|
pub struct Activity {
|
||||||
|
/// Name of the Discord Application - Read Only.
|
||||||
#[serde(skip_serializing)]
|
#[serde(skip_serializing)]
|
||||||
name: String,
|
name: String,
|
||||||
|
|
||||||
|
/// Type of Activity - Will be discarded by Discord App.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
activity_type: Option<i8>,
|
activity_type: Option<i8>,
|
||||||
|
|
||||||
|
/// Livestream URL, accepts only Twitch and Youtube links - Will be discarded by Discord App.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
url: Option<String>,
|
url: Option<String>,
|
||||||
|
|
||||||
|
/// Time of creation of the Activity.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
created_at: Option<u128>,
|
created_at: Option<u128>,
|
||||||
|
|
||||||
|
/// Timestamps for the Activity. Used to set the "elapsed / remaining" countdown on Discord Activity.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
timestamps: Option<Timestamp>,
|
timestamps: Option<Timestamp>,
|
||||||
|
|
||||||
|
/// ID of Discord Application provided when instantiating DiscordClient.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
application_id: Option<i32>,
|
application_id: Option<i32>,
|
||||||
|
|
||||||
|
/// First line of Discord Activity.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
details: Option<String>,
|
details: Option<String>,
|
||||||
|
|
||||||
|
/// Second line of Discord Activity.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
state: Option<String>,
|
state: Option<String>,
|
||||||
|
|
||||||
|
/// Sets a custom Emoji on the Discord Activity - Will be discarded by Discord App.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
emoji: Option<Emoji>,
|
emoji: Option<Emoji>,
|
||||||
|
|
||||||
|
/// Adds a player count after the State.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
party: Option<Party>,
|
party: Option<Party>,
|
||||||
|
|
||||||
|
/// Activity Large image and Small image.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
assets: Option<Asset>,
|
assets: Option<Asset>,
|
||||||
|
|
||||||
|
/// Adds a Secret URI to the activity to enable Chat Join messages.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
secrets: Option<Secret>,
|
secrets: Option<Secret>,
|
||||||
|
|
||||||
|
/// Whether activity is in an Instance context, like an ongoing match.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
instance: Option<bool>,
|
instance: Option<bool>,
|
||||||
|
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
flags: Option<i8>,
|
flags: Option<i8>,
|
||||||
|
|
||||||
|
/// List of buttons added at the bottom of the Activity. Up to 2 buttons are supported by Discord.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
buttons: Option<Vec<Button>>,
|
buttons: Option<Vec<Button>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Activity {
|
impl Activity {
|
||||||
|
/// Instantiates a new Activity.
|
||||||
pub fn new() -> Activity {
|
pub fn new() -> Activity {
|
||||||
Self {
|
Self {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
|
|
@ -75,11 +92,13 @@ impl Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a name for the Activity - Will be discarded by Discord App.
|
||||||
pub fn set_name(&mut self, name: String) -> &mut Self {
|
pub fn set_name(&mut self, name: String) -> &mut Self {
|
||||||
self.name = name;
|
self.name = name;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a new ActivityType - Will be discarded by Discord App.
|
||||||
pub fn set_activity_type(&mut self, activity_type: Option<ActivityType>) -> &mut Self {
|
pub fn set_activity_type(&mut self, activity_type: Option<ActivityType>) -> &mut Self {
|
||||||
match activity_type {
|
match activity_type {
|
||||||
Some(val) => self.activity_type = Some(val as i8),
|
Some(val) => self.activity_type = Some(val as i8),
|
||||||
|
|
@ -89,61 +108,73 @@ impl Activity {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a streaming URL.
|
||||||
pub fn set_url(&mut self, url: Option<String>) -> &mut Self {
|
pub fn set_url(&mut self, url: Option<String>) -> &mut Self {
|
||||||
self.url = url;
|
self.url = url;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a created_at for the Activity.
|
||||||
pub fn set_created_at(&mut self, created_at: Option<u128>) -> &mut Self {
|
pub fn set_created_at(&mut self, created_at: Option<u128>) -> &mut Self {
|
||||||
self.created_at = created_at;
|
self.created_at = created_at;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets new Timestamps for the Activity.
|
||||||
pub fn set_timestamps(&mut self, timestamps: Option<Timestamp>) -> &mut Self {
|
pub fn set_timestamps(&mut self, timestamps: Option<Timestamp>) -> &mut Self {
|
||||||
self.timestamps = timestamps;
|
self.timestamps = timestamps;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets an Application ID for the Activity - Will be discarded by Discord App.
|
||||||
pub fn set_application_id(&mut self, application_id: Option<i32>) -> &mut Self {
|
pub fn set_application_id(&mut self, application_id: Option<i32>) -> &mut Self {
|
||||||
self.application_id = application_id;
|
self.application_id = application_id;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the details for the current Activity.
|
||||||
pub fn set_details(&mut self, details: Option<String>) -> &mut Self {
|
pub fn set_details(&mut self, details: Option<String>) -> &mut Self {
|
||||||
self.details = details;
|
self.details = details;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a state for the current Activity.
|
||||||
pub fn set_state(&mut self, state: Option<String>) -> &mut Self {
|
pub fn set_state(&mut self, state: Option<String>) -> &mut Self {
|
||||||
self.state = state;
|
self.state = state;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets an emoji for the current Activity.
|
||||||
pub fn set_emoji(&mut self, emoji: Option<Emoji>) -> &mut Self {
|
pub fn set_emoji(&mut self, emoji: Option<Emoji>) -> &mut Self {
|
||||||
self.emoji = emoji;
|
self.emoji = emoji;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the party count for the current Activity.
|
||||||
pub fn set_party(&mut self, party: Option<Party>) -> &mut Self {
|
pub fn set_party(&mut self, party: Option<Party>) -> &mut Self {
|
||||||
self.party = party;
|
self.party = party;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the Image Assets for the current Activity.
|
||||||
pub fn set_assets(&mut self, assets: Option<Asset>) -> &mut Self {
|
pub fn set_assets(&mut self, assets: Option<Asset>) -> &mut Self {
|
||||||
self.assets = assets;
|
self.assets = assets;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a Secret for the current Activity.
|
||||||
pub fn set_secrets(&mut self, secrets: Option<Secret>) -> &mut Self {
|
pub fn set_secrets(&mut self, secrets: Option<Secret>) -> &mut Self {
|
||||||
self.secrets = secrets;
|
self.secrets = secrets;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the instance boolean for the current Activity.
|
||||||
pub fn set_instance(&mut self, instance: Option<bool>) -> &mut Self {
|
pub fn set_instance(&mut self, instance: Option<bool>) -> &mut Self {
|
||||||
self.instance = instance;
|
self.instance = instance;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the flags for the current Activity.
|
||||||
pub fn set_flags(&mut self, flag: Option<ActivityFlag>) -> &mut Self {
|
pub fn set_flags(&mut self, flag: Option<ActivityFlag>) -> &mut Self {
|
||||||
match flag {
|
match flag {
|
||||||
Some(val) => self.flags = Some(val as i8),
|
Some(val) => self.flags = Some(val as i8),
|
||||||
|
|
@ -153,6 +184,7 @@ impl Activity {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the Buttons for the current Activity. Up to 2 buttons are supported by Discord.
|
||||||
pub fn set_buttons(&mut self, buttons: Option<Vec<Button>>) -> &mut Self {
|
pub fn set_buttons(&mut self, buttons: Option<Vec<Button>>) -> &mut Self {
|
||||||
self.buttons = buttons;
|
self.buttons = buttons;
|
||||||
self
|
self
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue