Class ClientActivity

java.lang.Object
discord4j.core.object.presence.ClientActivity

public class ClientActivity extends Object
Activity data that can be sent to Discord.

This is as opposed to Activity which is received from Discord.

An activity is combined with a Status to create a ClientPresence.

  • Method Details

    • playing

      public static ClientActivity playing(String name)
      Creates a playing activity.
      Parameters:
      name - the name of the activity
      Returns:
      a playing activity with the given name
    • streaming

      public static ClientActivity streaming(String name, String url)
      Creates a streaming activity.
      Parameters:
      name - the name of the activity
      url - the stream url
      Returns:
      a streaming activity with the given name and url
    • listening

      public static ClientActivity listening(String name)
      Creates a listening activity.
      Parameters:
      name - the name of the activity
      Returns:
      a listening activity with the given name
    • watching

      public static ClientActivity watching(String name)
      Creates a watching activity.
      Parameters:
      name - the name of the activity
      Returns:
      a watching activity with the given name
    • competing

      public static ClientActivity competing(String name)
      Creates a competing activity.
      Parameters:
      name - the name of the activity
      Returns:
      a competing activity with the given name
    • custom

      public static ClientActivity custom(String name)
      Creates a custom activity.
      Parameters:
      name - the custom status used in this activity
      Returns:
      a custom activity with the given "state" value
    • of

      public static ClientActivity of(Activity.Type type, String name, @Nullable String url)
      Creates an activity with the given type, name, and url.
      Parameters:
      type - the type of the activity
      name - the name of the activity
      url - the url of the activity (only valid for streaming activities)
      Returns:
      an activity with the given type, name, and url
    • of

      public static ClientActivity of(Activity.Type type, String name, @Nullable String url, @Nullable String state)
      Creates an activity with the given type, name, url and state.
      Parameters:
      type - the type of the activity
      name - the name of the activity
      url - the url of the activity if the type is STREAMING
      state - the status if the type is CUSTOM, or shown as additional data under an activity's name for other types
      Returns:
      an activity with the given type, name, url and state
    • withState

      public ClientActivity withState(String state)
      Create a new ClientActivity from this one by including the given "state" field value. For activity types other than Activity.Type.CUSTOM, it will be shown as additional data under an activity's name.
      Parameters:
      state - the custom status or additional data to include under an activity
      Returns:
      a new client activity based on this one with the given state value
    • getActivityUpdateRequest

      public discord4j.discordjson.json.ActivityUpdateRequest getActivityUpdateRequest()
      Converts this activity's data to an object for use by the gateway.
      Returns:
      an equivalent ActivityUpdateRequest for this activity