Class UserActivityEndEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.user.GenericUserEvent
-
- net.dv8tion.jda.api.events.user.UserActivityEndEvent
-
- All Implemented Interfaces:
GenericEvent
,GenericUserPresenceEvent
public class UserActivityEndEvent extends GenericUserEvent implements GenericUserPresenceEvent
Indicates that aUser
has stopped anActivity
in aGuild
.This is fired for every
Guild
the user is part of. If the title of a stream changes a start event is fired before an end event which will replace the activity.The activities of the
Member
are updated before all start/end events are fired. This means you can checkMember.getActivities()
when handling this event and it will already contain all new activities, even ones that have not yet fired the start event.To check whether the activity has concluded rather than was replaced due to an update of one of its properties such as name you can check
Member.getActivities()
. Iterate the list of activities and check if an activity of the sametype
exists, if that is the case it was replaced and not finished.Requirements
This event requires the
GUILD_PRESENCES
intent to be enabled.createDefault(String)
andcreateLight(String)
disable this by default!Additionally, this event requires the
MemberCachePolicy
to cache the updated members. Discord does not specifically tell us about the updates, but merely tells us the member was updated and gives us the updated member object. In order to fire a specific event like this we need to have the old member cached to compare against.This also requires
CacheFlag.ACTIVITY
to be enabled. You can enable the cache flag withenableCache(CacheFlag.ACTIVITY)
.
-
-
Constructor Summary
Constructors Constructor Description UserActivityEndEvent(JDA api, long responseNumber, Member member, Activity oldActivity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Guild
getGuild()
Guild in which the presence has changed.Member
getMember()
Member who changed their presence.Activity
getOldActivity()
The old activity-
Methods inherited from class net.dv8tion.jda.api.events.user.GenericUserEvent
getUser
-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.dv8tion.jda.api.events.GenericEvent
getJDA, getResponseNumber
-
-
-
-
Method Detail
-
getOldActivity
@Nonnull public Activity getOldActivity()
The old activity- Returns:
- The old activity
-
getGuild
@Nonnull public Guild getGuild()
Description copied from interface:GenericUserPresenceEvent
Guild in which the presence has changed.- Specified by:
getGuild
in interfaceGenericUserPresenceEvent
- Returns:
- The guild
-
getMember
@Nonnull public Member getMember()
Description copied from interface:GenericUserPresenceEvent
Member who changed their presence.- Specified by:
getMember
in interfaceGenericUserPresenceEvent
- Returns:
- The member
-
-