Package net.dv8tion.jda.api.entities
Interface Activity
- All Known Subinterfaces:
RichPresence
public interface Activity
Represents a Discord
This should contain all information provided from Discord about a Activity.
Activity
.
This should contain all information provided from Discord about a Activity.
- Since:
- 2.1
- Author:
- John A. Grosh
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The activity being executed, differentiating between, amongst others, playing, listening and streaming.static class
Emoji for a custom status.static class
Represents the start and end timestamps for a running match -
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
The Pattern used forisValidStreamingUrl(String)
-
Method Summary
Modifier and TypeMethodDescriptionRichPresence
representation of this Activity.static Activity
Creates a new Activity instance with the specified name.getEmoji()
The emoji (or custom emoji) attached to a custom status.getName()
The displayed name of theActivity
.Information on the match duration, start, and end.getType()
The type ofActivity
.getUrl()
The URL of theActivity
if the game is actually a Stream.boolean
isRich()
static boolean
Checks if a given String is a valid Twitch/Youtube streaming url (ie, one that will display "Streaming" on the Discord client).static Activity
Creates a new Activity instance with the specified name.static Activity
of
(Activity.ActivityType type, String name) Creates a new Activity instance with the specified name.static Activity
of
(Activity.ActivityType type, String name, String url) Creates a new Activity instance with the specified name and url.static Activity
Creates a new Activity instance with the specified name.static Activity
Creates a new Activity instance with the specified name and url.static Activity
Creates a new Activity instance with the specified name.
-
Field Details
-
STREAMING_URL
The Pattern used forisValidStreamingUrl(String)
-
-
Method Details
-
isRich
boolean isRich()- Returns:
true
if this is aRichPresence
-
asRichPresence
RichPresence
representation of this Activity.- Returns:
- RichPresence or
null
ifisRich()
returnsfalse
-
getName
The displayed name of theActivity
.
ForActivity.ActivityType.CUSTOM_STATUS
this will return the custom status text.- Returns:
- String containing the Activity's name.
-
getUrl
The URL of theActivity
if the game is actually a Stream.
This will return null for regular games.- Returns:
- Possibly-null String containing the Activity's URL.
-
getType
The type ofActivity
.- Returns:
- Never-null
ActivityType
representing the type of Activity
-
getTimestamps
Information on the match duration, start, and end.- Returns:
Timestamps
wrapper ofnull
if unset
-
getEmoji
The emoji (or custom emoji) attached to a custom status.- Returns:
- Possibly-null
Activity.Emoji
used for custom status
-
playing
Creates a new Activity instance with the specified name.
In order to appear as "streaming" in the official client you must provide a valid (see documentation of method) streaming URL inActivity.streaming(String, String)
.- Parameters:
name
- The not-null name of the newly created game- Returns:
- A valid Activity instance with the provided name with
Activity.ActivityType.PLAYING
- Throws:
IllegalArgumentException
- if the specified name is null, empty, blank or longer than 128 characters
-
streaming
Creates a new Activity instance with the specified name and url.
The specified URL must be valid according to discord standards in order to display as "streaming" in the official client. A valid streaming URL must be derived fromhttps://twitch.tv/
orhttps://youtube.com/watch?v=
and can be verified usingisValidStreamingUrl(String)
. (see documentation)- Parameters:
name
- The not-null name of the newly created gameurl
- The streaming url to use, required to display as "streaming"- Returns:
- A valid Activity instance with the provided name and url
- Throws:
IllegalArgumentException
- If the specified name is null, empty or longer than 128 characters- See Also:
-
listening
Creates a new Activity instance with the specified name.
This will display asListening name
in the official client- Parameters:
name
- The not-null name of the newly created game- Returns:
- A valid Activity instance with the provided name with
Activity.ActivityType.LISTENING
- Throws:
IllegalArgumentException
- if the specified name is null, empty, blank or longer than 128 characters
-
watching
Creates a new Activity instance with the specified name.
This will display asWatching name
in the official client- Parameters:
name
- The not-null name of the newly created game- Returns:
- A valid Activity instance with the provided name with
Activity.ActivityType.WATCHING
- Throws:
IllegalArgumentException
- if the specified name is null, empty, blank or longer than 128 characters- Incubating:
- This feature is not yet confirmed for the official bot API
-
competing
Creates a new Activity instance with the specified name.
This will display asCompeting in name
in the official client- Parameters:
name
- The not-null name of the newly created game- Returns:
- A valid Activity instance with the provided name with
Activity.ActivityType.COMPETING
- Throws:
IllegalArgumentException
- If the specified name is null, empty, blank or longer than 128 characters- Since:
- 4.2.1
-
of
Creates a new Activity instance with the specified name.- Parameters:
type
- TheActivityType
to usename
- The not-null name of the newly created game- Returns:
- A valid Activity instance with the provided name
- Throws:
IllegalArgumentException
-- If the specified ActivityType is null or unsupported
- If the specified name is null, empty or longer than 128 characters
-
of
@Nonnull static Activity of(@Nonnull Activity.ActivityType type, @Nonnull String name, @Nullable String url) Creates a new Activity instance with the specified name and url.
The provided url would only be used forActivityType.STREAMING
and should be a twitch url.- Parameters:
type
- TheActivityType
to usename
- The not-null name of the newly created gameurl
- The streaming url to use, required to display as "streaming".- Returns:
- A valid Activity instance with the provided name and url
- Throws:
IllegalArgumentException
-- If the specified ActivityType is null or unsupported
- If the specified name is null, empty or longer than 128 characters
- See Also:
-
isValidStreamingUrl
Checks if a given String is a valid Twitch/Youtube streaming url (ie, one that will display "Streaming" on the Discord client).- Parameters:
url
- The url to check.- Returns:
- True if the provided url is valid for triggering Discord's streaming status
-