Skip to content

Commit

Permalink
Add some missing documentation to clarify cache (#2306)
Browse files Browse the repository at this point in the history
* Add docs for scheduled events cache

* Add docs for online status cache
  • Loading branch information
MinnDevelopment committed Oct 28, 2022
1 parent 59c7a9c commit 5bab345
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 22 deletions.
10 changes: 10 additions & 0 deletions src/main/java/net/dv8tion/jda/api/JDA.java
Expand Up @@ -1242,6 +1242,8 @@ default List<Role> getRolesByName(@Nonnull String name, boolean ignoreCase)
* {@link SnowflakeCacheView} of
* all cached {@link ScheduledEvent ScheduledEvents} visible to this JDA session.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @return {@link SnowflakeCacheView}
*/
@Nonnull
Expand All @@ -1256,6 +1258,8 @@ default List<Role> getRolesByName(@Nonnull String name, boolean ignoreCase)
* a local variable or use {@link #getScheduledEventCache()} and use its more efficient
* versions of handling these values.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @return Possibly-empty immutable list of all known {@link ScheduledEvent ScheduledEvents}.
*/
@Nonnull
Expand All @@ -1269,6 +1273,8 @@ default List<ScheduledEvent> getScheduledEvents()
* <br>If there is no known {@link ScheduledEvent} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param id
* The id of the {@link ScheduledEvent}.
*
Expand All @@ -1288,6 +1294,8 @@ default ScheduledEvent getScheduledEventById(@Nonnull String id)
* <br>If there is no known {@link ScheduledEvent} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param id
* The id of the {@link ScheduledEvent}.
*
Expand All @@ -1303,6 +1311,8 @@ default ScheduledEvent getScheduledEventById(long id)
* An unmodifiable list of all {@link ScheduledEvent ScheduledEvents} that have the same name as the one provided.
* <br>If there are no {@link ScheduledEvent ScheduledEvents} with the provided name, then this returns an empty list.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param name
* The name of the requested {@link ScheduledEvent}.
* @param ignoreCase
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/Guild.java
Expand Up @@ -1280,6 +1280,8 @@ default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
* <br>Scheduled events are sorted by their start time, and events that start at the same time
* are sorted by their snowflake ID.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @return {@link SortedSnowflakeCacheView}
*/
@Nonnull
Expand All @@ -1291,6 +1293,8 @@ default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
* <br>If there are no {@link ScheduledEvent ScheduledEvents} with the provided name,
* then this returns an empty list.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param name
* The name used to filter the returned {@link ScheduledEvent} objects.
* @param ignoreCase
Expand All @@ -1314,6 +1318,8 @@ default List<ScheduledEvent> getScheduledEventsByName(@Nonnull String name, bool
* <br>If there is no {@link ScheduledEvent} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param id
* The id of the {@link ScheduledEvent}.
*
Expand All @@ -1335,6 +1341,8 @@ default ScheduledEvent getScheduledEventById(@Nonnull String id)
* <br>If there is no {@link ScheduledEvent} with an id that matches the provided
* one, then this returns {@code null}.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @param id
* The id of the {@link ScheduledEvent}.
*
Expand All @@ -1356,6 +1364,8 @@ default ScheduledEvent getScheduledEventById(long id)
* a local variable or use {@link #getScheduledEventCache()} and use its more efficient
* versions of handling these values.
*
* <p>This requires {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
*
* @return Possibly-empty immutable List of {@link ScheduledEvent ScheduledEvents}.
*/
@Nonnull
Expand Down
Expand Up @@ -18,6 +18,7 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.events.guild.GenericGuildEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -31,11 +32,11 @@
*
* <p><b>Requirements</b><br>
*
* <p>These events require the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>These events require the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
* <p> This class may be used to check if a gateway event is related to a {@link ScheduledEvent}
* <p>This class may be used to check if a gateway event is related to a {@link ScheduledEvent}
* as all gateway events in the {@link net.dv8tion.jda.api.events.guild.scheduledevent} package extend this class.
*/
public abstract class GenericScheduledEventGatewayEvent extends GenericGuildEvent
Expand Down
Expand Up @@ -16,11 +16,12 @@
package net.dv8tion.jda.api.events.guild.scheduledevent;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.requests.restaction.CacheRestAction;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
Expand All @@ -31,7 +32,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -25,7 +26,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -25,7 +26,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -25,7 +26,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -25,7 +26,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -4,6 +4,7 @@
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.events.UpdateEvent;
import net.dv8tion.jda.api.events.guild.scheduledevent.GenericScheduledEventGatewayEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -20,7 +21,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>These events require the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>These events require the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -30,7 +31,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -31,7 +32,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -29,7 +30,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -29,7 +30,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -29,7 +30,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;
import java.time.OffsetDateTime;
Expand All @@ -30,7 +31,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,6 +17,7 @@

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.ScheduledEvent;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

Expand All @@ -30,7 +31,7 @@
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent to be enabled.
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
*
Expand Down
Expand Up @@ -17,26 +17,31 @@
package net.dv8tion.jda.api.events.user.update;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
import net.dv8tion.jda.api.utils.cache.CacheFlag;

import javax.annotation.Nonnull;

/**
* Indicates that the {@link OnlineStatus OnlineStatus} of a {@link net.dv8tion.jda.api.entities.User User} changed.
* <br>As with any presence updates this happened for a {@link net.dv8tion.jda.api.entities.Member Member} in a Guild!
* Indicates that the {@link OnlineStatus} of a {@link User} changed.
* <br>As with any presence updates this happened for a {@link Member} in a Guild!
* <p>Can be used to retrieve the User who changed their status and their previous status.
*
* <p>Identifier: {@code status}
*
* <p><b>Requirements</b><br>
*
* <p>This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_PRESENCES GUILD_PRESENCES} intent to be enabled.
* <br>{@link net.dv8tion.jda.api.JDABuilder#createDefault(String) createDefault(String)} and
* {@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disable this by default!
* <p>This event requires the {@link GatewayIntent#GUILD_PRESENCES GUILD_PRESENCES} intent and {@link CacheFlag#ONLINE_STATUS} to be enabled.
* <br>{@link JDABuilder#createDefault(String) createDefault(String)} and
* {@link JDABuilder#createLight(String) createLight(String)} disable this by default!
*
* <p>Additionally, this event requires the {@link net.dv8tion.jda.api.utils.MemberCachePolicy MemberCachePolicy}
* <p>Additionally, this event requires the {@link 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.
Expand Down

0 comments on commit 5bab345

Please sign in to comment.