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

#[non_exhaustive]
pub struct Activity {
Show 16 fields 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 sync_id: Option<String>, pub session_id: Option<String>, pub url: Option<String>, pub buttons: Vec<ActivityButton>,
}
Expand description

Representation of an activity that a User is performing.

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.
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.

sync_id: Option<String>

The sync ID of the activity. Mainly used by the Spotify activity type which uses this parameter to store the track ID.

session_id: Option<String>

The session ID of the activity. Reserved for specific activity types, such as the Activity that is transmitted when a user is listening to Spotify.

url: Option<String>

The Stream URL if Self::kind is ActivityType::Streaming.

buttons: Vec<ActivityButton>

The buttons of this activity.

Note: There can only be up to 2 buttons.

Implementations

Creates a Activity 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::client::Context;
use serenity::framework::standard::{macros::command, Args, CommandResult};
use serenity::model::channel::Message;
use serenity::model::gateway::Activity;

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

    Ok(())
}

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::client::Context;
use serenity::framework::standard::{macros::command, Args, CommandResult};
use serenity::model::channel::Message;
use serenity::model::gateway::Activity;

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

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

    Ok(())
}

Creates a Activity 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::client::Context;
use serenity::framework::standard::{macros::command, Args, CommandResult};
use serenity::model::channel::Message;
use serenity::model::gateway::Activity;

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

    Ok(())
}

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

Note: Maximum name length is 128.

Examples

Create a command that sets the current cometing status:

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

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

    Ok(())
}

Creates a Activity struct that appears as a Competing in <name> status.

Note: Maximum name length is 128.

Examples

Create a command that sets the current cometing status:

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

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

    Ok(())
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more