[][src]Struct serenity::model::gateway::Activity

pub struct Activity {
    pub application_id: Option<ApplicationId>,
    pub assets: Option<ActivityAssets>,
    pub details: Option<String>,
    pub flags: Option<ActivityFlags>,
    pub instance: Option<bool>,
    pub kind: ActivityType,
    pub name: String,
    pub party: Option<ActivityParty>,
    pub secrets: Option<ActivitySecrets>,
    pub state: Option<String>,
    pub emoji: Option<ActivityEmoji>,
    pub timestamps: Option<ActivityTimestamps>,
    pub url: Option<String>,
    // some fields omitted
}

Representation of an activity that a User is performing.

Fields

application_id: Option<ApplicationId>

The ID of the application for the activity.

assets: Option<ActivityAssets>

Images for the presence and their texts.

details: Option<String>

What the user is doing.

flags: Option<ActivityFlags>

Activity flags describing what the payload includes.

instance: Option<bool>

Whether or not the activity is an instanced game session.

kind: ActivityType

The type of activity being performed

name: String

The name of the activity.

party: Option<ActivityParty>

Information about the user's current party.

secrets: Option<ActivitySecrets>

Secrets for Rich Presence joining and spectating.

state: Option<String>

The user's current party status.

emoji: Option<ActivityEmoji>

Emoji currently used in custom status

timestamps: Option<ActivityTimestamps>

Unix timestamps for the start and/or end times of the activity.

url: Option<String>

The Stream URL if kind is ActivityType::Streaming.

Methods

impl Activity[src]

pub fn playing(name: &str) -> Activity[src]

Creates a Game struct that appears as a Playing <name> status.

Note: Maximum name length is 128.

Examples

Create a command that sets the current activity:

use serenity::model::gateway::Activity;
use serenity::model::channel::Message;
use serenity::framework::standard::{Args, CommandResult, macros::command};
use serenity::client::Context;

#[command]
fn activity(ctx: &mut Context, _msg: &Message, args: Args) -> CommandResult {
    let name = args.message();
    ctx.set_activity(Activity::playing(&name));

    Ok(())
}

pub fn streaming(name: &str, url: &str) -> Activity[src]

Creates an Activity struct that appears as a Streaming <name> status.

Note: Maximum name length is 128.

Examples

Create a command that sets the current streaming status:

use serenity::model::gateway::Activity;
use serenity::model::channel::Message;
use serenity::framework::standard::{Args, CommandResult, macros::command};
use serenity::client::Context;

#[command]
fn stream(ctx: &mut Context, _msg: &Message, args: Args) -> CommandResult {
    const STREAM_URL: &str = "...";

    let name = args.message();
    ctx.set_activity(Activity::streaming(&name, STREAM_URL));

    Ok(())
}

pub fn listening(name: &str) -> Activity[src]

Creates a Game struct that appears as a Listening to <name> status.

Note: Maximum name length is 128.

Examples

Create a command that sets the current listening status:

use serenity::model::gateway::Activity;
use serenity::model::channel::Message;
use serenity::framework::standard::{Args, CommandResult, macros::command};
use serenity::client::Context;

#[command]
fn listen(ctx: &mut Context, _msg: &Message, args: Args) -> CommandResult {
    let name = args.message();
    ctx.set_activity(Activity::listening(&name));

    Ok(())
}

Trait Implementations

impl Clone for Activity[src]

impl Debug for Activity[src]

impl<'de> Deserialize<'de> for Activity[src]

impl Serialize for Activity[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> DebugAny for T where
    T: Any + Debug
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,