diff --git a/src/main/java/net/dv8tion/jda/api/events/annotations/Requirements.java b/src/main/java/net/dv8tion/jda/api/events/annotations/Requirements.java new file mode 100644 index 0000000000..5df2144a65 --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/events/annotations/Requirements.java @@ -0,0 +1,37 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.dv8tion.jda.api.events.annotations; + +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; + +import java.lang.annotation.*; + +//TODO docs +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Requirements +{ + GatewayIntent[] intents() default {}; + + GatewayIntent[] optionalIntents() default {}; + + CacheFlag[] cache() default {}; + + CacheFlag[] optionalCache() default {}; +} diff --git a/src/main/java/net/dv8tion/jda/api/events/annotations/RequiresCachedMember.java b/src/main/java/net/dv8tion/jda/api/events/annotations/RequiresCachedMember.java new file mode 100644 index 0000000000..0ee7d584b7 --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/events/annotations/RequiresCachedMember.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.dv8tion.jda.api.events.annotations; + +import java.lang.annotation.*; + +//TODO docs, explain cache policy, chunking and user actions adding them to the cache +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RequiresCachedMember +{ +} diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java index 25c2a51ffc..31306ef850 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagAddEvent.java @@ -19,6 +19,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -33,6 +35,7 @@ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled. * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default. */ +@Requirements(cache = CacheFlag.FORUM_TAGS) public class ForumTagAddEvent extends GenericForumTagEvent { public ForumTagAddEvent(@Nonnull JDA api, long responseNumber, @Nonnull IPostContainer channel, @Nonnull ForumTag tag) diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java index 3b4ee3103e..85f945a062 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/ForumTagRemoveEvent.java @@ -19,6 +19,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -33,6 +35,7 @@ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled. * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default. */ +@Requirements(cache = CacheFlag.FORUM_TAGS) public class ForumTagRemoveEvent extends GenericForumTagEvent { public ForumTagRemoveEvent(@Nonnull JDA api, long responseNumber, @Nonnull IPostContainer channel, @Nonnull ForumTag tag) diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java index 95226446d5..34f51e4f46 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/GenericForumTagEvent.java @@ -21,6 +21,8 @@ import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; import net.dv8tion.jda.api.events.Event; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -32,6 +34,7 @@ * This requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#FORUM_TAGS CacheFlag.FORUM_TAGS} to be enabled. * {@link net.dv8tion.jda.api.JDABuilder#createLight(String, Collection) JDABuilder.createLight(...)} disables this by default. */ +@Requirements(cache = CacheFlag.FORUM_TAGS) public abstract class GenericForumTagEvent extends Event { protected final IPostContainer channel; diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java index 22ec23c96d..fa70bf1c36 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateEmojiEvent.java @@ -20,6 +20,8 @@ import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; import net.dv8tion.jda.api.entities.emoji.EmojiUnion; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -34,6 +36,7 @@ * *

Identifier: {@code emoji} */ +@Requirements(cache = CacheFlag.FORUM_TAGS) public class ForumTagUpdateEmojiEvent extends GenericForumTagUpdateEvent { public static final String IDENTIFIER = "emoji"; diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateModeratedEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateModeratedEvent.java index 586c0bc1e3..0fcdaef32c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateModeratedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateModeratedEvent.java @@ -19,6 +19,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -32,6 +34,7 @@ * *

Identifier: {@code moderated} */ +@Requirements(cache = CacheFlag.FORUM_TAGS) @SuppressWarnings("ConstantConditions") public class ForumTagUpdateModeratedEvent extends GenericForumTagUpdateEvent { diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateNameEvent.java index 677428e8ec..fee94a9d8d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/ForumTagUpdateNameEvent.java @@ -19,6 +19,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -32,6 +34,7 @@ * *

Identifier: {@code name} */ +@Requirements(cache = CacheFlag.FORUM_TAGS) @SuppressWarnings("ConstantConditions") public class ForumTagUpdateNameEvent extends GenericForumTagUpdateEvent { diff --git a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/GenericForumTagUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/GenericForumTagUpdateEvent.java index 4c44aabb39..897c086dc4 100644 --- a/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/GenericForumTagUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/channel/forum/update/GenericForumTagUpdateEvent.java @@ -20,7 +20,9 @@ import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.forums.ForumTag; import net.dv8tion.jda.api.events.UpdateEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.channel.forum.GenericForumTagEvent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Collection; @@ -35,6 +37,7 @@ * @param * The type of the updated field */ +@Requirements(cache = CacheFlag.FORUM_TAGS) public abstract class GenericForumTagUpdateEvent extends GenericForumTagEvent implements UpdateEvent { private final T previous; diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java index 5af0d65207..fc9f6244e0 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java @@ -18,6 +18,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -31,6 +34,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public class EmojiAddedEvent extends GenericEmojiEvent { public EmojiAddedEvent(@Nonnull JDA api, long responseNumber, @Nonnull RichCustomEmoji emoji) diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java index 7a910f17bc..e3b994e872 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java @@ -18,6 +18,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -31,6 +34,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public class EmojiRemovedEvent extends GenericEmojiEvent { public EmojiRemovedEvent(@Nonnull JDA api, long responseNumber, @Nonnull RichCustomEmoji emoji) diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java index efd55eeb28..75e8ef1da9 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java @@ -20,6 +20,9 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; import net.dv8tion.jda.api.events.Event; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -33,6 +36,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public abstract class GenericEmojiEvent extends Event { protected final RichCustomEmoji emoji; diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java index 94e6095cbb..44fbd44f64 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java @@ -18,6 +18,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -35,6 +38,7 @@ * *

Identifier: {@code name} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public class EmojiUpdateNameEvent extends GenericEmojiUpdateEvent { public static final String IDENTIFIER = "name"; diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java index 4f45dafd69..92fd42d75a 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.List; @@ -37,6 +40,7 @@ * *

Identifier: {@code roles} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public class EmojiUpdateRolesEvent extends GenericEmojiUpdateEvent> { public static final String IDENTIFIER = "roles"; diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java index 1a50e129dc..7b384752a8 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java @@ -19,7 +19,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; import net.dv8tion.jda.api.events.UpdateEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.emoji.GenericEmojiEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -34,6 +37,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.EMOJI) public abstract class GenericEmojiUpdateEvent extends GenericEmojiEvent implements UpdateEvent { protected final T previous; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java index 404e7472a4..c86d70442c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java @@ -25,6 +25,7 @@ import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer; import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.entities.channel.unions.IPermissionContainerUnion; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.guild.GenericGuildEvent; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -43,6 +44,7 @@ * unless the member is the {@link net.dv8tion.jda.api.entities.Guild#getSelfMember() self member}. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(optionalCache = CacheFlag.MEMBER_OVERRIDES) public class GenericPermissionOverrideEvent extends GenericGuildEvent { protected final IPermissionContainer channel; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideCreateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideCreateEvent.java index c41e133f5d..9bbc15c29b 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideCreateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideCreateEvent.java @@ -19,6 +19,7 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.PermissionOverride; import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -37,6 +38,7 @@ * unless the member is the {@link net.dv8tion.jda.api.entities.Guild#getSelfMember() self member}. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(optionalCache = CacheFlag.MEMBER_OVERRIDES) public class PermissionOverrideCreateEvent extends GenericPermissionOverrideEvent { public PermissionOverrideCreateEvent(@Nonnull JDA api, long responseNumber, @Nonnull IPermissionContainer channel, @Nonnull PermissionOverride override) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideDeleteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideDeleteEvent.java index b1d6d8cd21..28b0e27d9c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideDeleteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideDeleteEvent.java @@ -19,6 +19,7 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.PermissionOverride; import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -37,6 +38,7 @@ * unless the member is the {@link net.dv8tion.jda.api.entities.Guild#getSelfMember() self member}. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(optionalCache = CacheFlag.MEMBER_OVERRIDES) public class PermissionOverrideDeleteEvent extends GenericPermissionOverrideEvent { public PermissionOverrideDeleteEvent(@Nonnull JDA api, long responseNumber, @Nonnull IPermissionContainer channel, @Nonnull PermissionOverride override) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideUpdateEvent.java index f7213d04fa..7b4541d4cf 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/override/PermissionOverrideUpdateEvent.java @@ -20,6 +20,7 @@ import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.PermissionOverride; import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ * unless the member is the {@link net.dv8tion.jda.api.entities.Guild#getSelfMember() self member}. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(optionalCache = CacheFlag.MEMBER_OVERRIDES) public class PermissionOverrideUpdateEvent extends GenericPermissionOverrideEvent { private final long oldAllow, oldDeny; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventGatewayEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventGatewayEvent.java index 0356bdc946..4cb0afffa7 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventGatewayEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventGatewayEvent.java @@ -17,7 +17,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.guild.GenericGuildEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +40,7 @@ *

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. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public abstract class GenericScheduledEventGatewayEvent extends GenericGuildEvent { protected final ScheduledEvent scheduledEvent; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventUserEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventUserEvent.java index ac2853d428..27e1efd49c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventUserEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/GenericScheduledEventUserEvent.java @@ -19,6 +19,8 @@ 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.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.CacheRestAction; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -38,6 +40,7 @@ *

This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public abstract class GenericScheduledEventUserEvent extends GenericScheduledEventGatewayEvent { private final long userId; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventCreateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventCreateEvent.java index 3fea72b59b..8342349a8d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventCreateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventCreateEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -31,6 +33,7 @@ *

This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventCreateEvent extends GenericScheduledEventGatewayEvent { public ScheduledEventCreateEvent(@Nonnull JDA api, long responseNumber, @Nonnull ScheduledEvent scheduledEvent) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventDeleteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventDeleteEvent.java index 2c8907b7eb..0c9190a8e7 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventDeleteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventDeleteEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -31,6 +33,7 @@ *

This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventDeleteEvent extends GenericScheduledEventGatewayEvent { public ScheduledEventDeleteEvent(@Nonnull JDA api, long responseNumber, @Nonnull ScheduledEvent scheduledEvent) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserAddEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserAddEvent.java index 1f27dc8969..4ebfa3de96 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserAddEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserAddEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -32,6 +34,7 @@ *

This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUserAddEvent extends GenericScheduledEventUserEvent { public ScheduledEventUserAddEvent(@Nonnull JDA api, long responseNumber, @Nonnull ScheduledEvent scheduledEvent, long userId) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserRemoveEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserRemoveEvent.java index 0630abf372..05f830c4bb 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserRemoveEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/ScheduledEventUserRemoveEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -32,6 +34,7 @@ *

This event requires the {@link net.dv8tion.jda.api.requests.GatewayIntent#SCHEDULED_EVENTS SCHEDULED_EVENTS} intent and {@link CacheFlag#SCHEDULED_EVENTS} to be enabled. *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables this by default! */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUserRemoveEvent extends GenericScheduledEventUserEvent { public ScheduledEventUserRemoveEvent(@Nonnull JDA api, long responseNumber, @Nonnull ScheduledEvent scheduledEvent, long userId) diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java index 6a8a805e4d..7b0b058d1d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java @@ -3,7 +3,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; import net.dv8tion.jda.api.events.UpdateEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.guild.scheduledevent.GenericScheduledEventGatewayEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -28,6 +30,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public abstract class GenericScheduledEventUpdateEvent extends GenericScheduledEventGatewayEvent implements UpdateEvent { protected final T previous; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateDescriptionEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateDescriptionEvent.java index c91b35fb43..bd93173619 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateDescriptionEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateDescriptionEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +40,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateDescriptionEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "description"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateEndTimeEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateEndTimeEvent.java index 6e00b4cd57..c474a6c6f5 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateEndTimeEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateEndTimeEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -39,6 +41,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateEndTimeEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "end_time"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateImageEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateImageEvent.java index fe4085a2da..1fd26fbf20 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateImageEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateImageEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -37,6 +39,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateImageEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "image"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateLocationEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateLocationEvent.java index 0416a0d409..15be2a09e3 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateLocationEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateLocationEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -37,6 +39,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateLocationEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "location"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateNameEvent.java index 16474a235e..851303a657 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateNameEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -37,6 +39,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateNameEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "name"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStartTimeEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStartTimeEvent.java index 15a5a496b4..d859f0c2c5 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStartTimeEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStartTimeEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +40,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateStartTimeEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "start_time"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStatusEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStatusEvent.java index 3b6386cca1..ecf05f877c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStatusEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/ScheduledEventUpdateStatusEvent.java @@ -17,6 +17,8 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.ScheduledEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +40,7 @@ * {@link ScheduledEvent ScheduledEvent} was updated and gives us the updated {@link ScheduledEvent ScheduledEvent} object. * In order to fire a specific event like this we need to have the old {@link ScheduledEvent ScheduledEvent} cached to compare against. */ +@Requirements(intents = GatewayIntent.SCHEDULED_EVENTS, cache = CacheFlag.SCHEDULED_EVENTS) public class ScheduledEventUpdateStatusEvent extends GenericScheduledEventUpdateEvent { public static final String IDENTIFIER = "status"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GenericGuildVoiceEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GenericGuildVoiceEvent.java index 18f010d201..50177592fb 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GenericGuildVoiceEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GenericGuildVoiceEvent.java @@ -19,7 +19,11 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.GuildVoiceState; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; import net.dv8tion.jda.api.events.guild.GenericGuildEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -41,6 +45,8 @@ * member was updated and gives us the updated member object. In order to fire specific events like these we * need to have the old member cached to compare against. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public abstract class GenericGuildVoiceEvent extends GenericGuildEvent { protected final Member member; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceDeafenEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceDeafenEvent.java index ac934a5969..65391c2612 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceDeafenEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceDeafenEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -40,6 +44,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceDeafenEvent extends GenericGuildVoiceEvent { protected final boolean deafened; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildDeafenEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildDeafenEvent.java index 41ee86ddaa..511d49c698 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildDeafenEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildDeafenEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +42,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceGuildDeafenEvent extends GenericGuildVoiceEvent { protected final boolean guildDeafened; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildMuteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildMuteEvent.java index 96bf9996e1..762a61129a 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildMuteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceGuildMuteEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +42,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceGuildMuteEvent extends GenericGuildVoiceEvent { protected final boolean guildMuted; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceMuteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceMuteEvent.java index 6bbddc7caa..f0f97b97cc 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceMuteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceMuteEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -40,6 +44,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceMuteEvent extends GenericGuildVoiceEvent { protected final boolean muted; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceRequestToSpeakEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceRequestToSpeakEvent.java index 0a9b8c2f48..592e4ce667 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceRequestToSpeakEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceRequestToSpeakEvent.java @@ -20,7 +20,11 @@ import net.dv8tion.jda.api.entities.GuildVoiceState; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.channel.concrete.StageChannel; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.requests.RestAction; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; @@ -45,6 +49,8 @@ * member was updated and gives us the updated member object. In order to fire specific events like these we * need to have the old member cached to compare against. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceRequestToSpeakEvent extends GenericGuildVoiceEvent { private final OffsetDateTime oldTime, newTime; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfDeafenEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfDeafenEvent.java index b50e3e3423..949dafe83c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfDeafenEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfDeafenEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +42,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceSelfDeafenEvent extends GenericGuildVoiceEvent { protected final boolean selfDeafened; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfMuteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfMuteEvent.java index ea85041d53..600862dc48 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfMuteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSelfMuteEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +42,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceSelfMuteEvent extends GenericGuildVoiceEvent { protected final boolean selfMuted; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceStreamEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceStreamEvent.java index da52a27f6e..e5a2dba785 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceStreamEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceStreamEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -38,6 +42,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceStreamEvent extends GenericGuildVoiceEvent { private final boolean stream; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSuppressEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSuppressEvent.java index aafd1151a0..016dacc05a 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSuppressEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceSuppressEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -40,6 +44,8 @@ * * @see net.dv8tion.jda.api.entities.GuildVoiceState#isSuppressed() GuildVoiceState.isSuppressed() */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceSuppressEvent extends GenericGuildVoiceEvent { protected final boolean suppressed; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceUpdateEvent.java index 0bf331af08..c52ceff38e 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceUpdateEvent.java @@ -21,6 +21,10 @@ import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion; import net.dv8tion.jda.api.events.UpdateEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -59,6 +63,8 @@ * *

Identifier: {@code audio-channel} */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceUpdateEvent extends GenericGuildVoiceEvent implements UpdateEvent { public static final String IDENTIFIER = "audio-channel"; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceVideoEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceVideoEvent.java index 9ee3d9a472..6838a54109 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceVideoEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/voice/GuildVoiceVideoEvent.java @@ -18,6 +18,10 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -39,6 +43,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_VOICE_STATES, cache = CacheFlag.VOICE_STATE) +@RequiresCachedMember public class GuildVoiceVideoEvent extends GenericGuildVoiceEvent { private final boolean video; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java index 67b74471e2..fd2cdc9c59 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java @@ -20,6 +20,9 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; import net.dv8tion.jda.api.events.Event; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -33,6 +36,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public abstract class GenericGuildStickerEvent extends Event { protected final Guild guild; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java index 515f8d60dc..2369123d67 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -32,6 +35,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerAddedEvent extends GenericGuildStickerEvent { public GuildStickerAddedEvent(@Nonnull JDA api, long responseNumber, diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java index df6d362409..15953e6727 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -32,6 +35,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerRemovedEvent extends GenericGuildStickerEvent { public GuildStickerRemovedEvent(@Nonnull JDA api, long responseNumber, diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java index d995e71546..9592315714 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java @@ -20,7 +20,10 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; import net.dv8tion.jda.api.events.UpdateEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.sticker.GenericGuildStickerEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -35,6 +38,7 @@ * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public abstract class GenericGuildStickerUpdateEvent extends GenericGuildStickerEvent implements UpdateEvent { protected final String identifier; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java index a347a7c6ad..2e4338687c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -34,6 +37,7 @@ * *

Identifier: {@code available} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerUpdateAvailableEvent extends GenericGuildStickerUpdateEvent { public static final String IDENTIFIER = "available"; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java index 70c29a215f..f85b2c0115 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -36,6 +39,7 @@ * *

Identifier: {@code description} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerUpdateDescriptionEvent extends GenericGuildStickerUpdateEvent { public static final String IDENTIFIER = "description"; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java index 22c6cf89cf..cb898e9cdd 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -36,6 +39,7 @@ * *

Identifier: {@code name} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerUpdateNameEvent extends GenericGuildStickerUpdateEvent { public static final String IDENTIFIER = "name"; diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java index 3f37aa8534..c650896b87 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java @@ -19,6 +19,9 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.sticker.GuildSticker; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.requests.GatewayIntent; +import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; import java.util.Set; @@ -37,6 +40,7 @@ * *

Identifier: {@code tags} */ +@Requirements(intents = GatewayIntent.GUILD_EMOJIS_AND_STICKERS, cache = CacheFlag.STICKER) public class GuildStickerUpdateTagsEvent extends GenericGuildStickerUpdateEvent> { public static final String IDENTIFIER = "tags"; diff --git a/src/main/java/net/dv8tion/jda/api/events/user/UserActivityEndEvent.java b/src/main/java/net/dv8tion/jda/api/events/user/UserActivityEndEvent.java index eabc2265e2..b3861f7d3d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/user/UserActivityEndEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/user/UserActivityEndEvent.java @@ -20,7 +20,10 @@ import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; import net.dv8tion.jda.api.events.user.update.GenericUserPresenceEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -55,6 +58,8 @@ *

This also requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#ACTIVITY CacheFlag.ACTIVITY} to be enabled. * You can enable the cache flag with {@link net.dv8tion.jda.api.JDABuilder#enableCache(CacheFlag, CacheFlag...) enableCache(CacheFlag.ACTIVITY)}. */ +@Requirements(intents = GatewayIntent.GUILD_PRESENCES, cache = CacheFlag.ACTIVITY) +@RequiresCachedMember public class UserActivityEndEvent extends GenericUserEvent implements GenericUserPresenceEvent { private final Activity oldActivity; diff --git a/src/main/java/net/dv8tion/jda/api/events/user/UserActivityStartEvent.java b/src/main/java/net/dv8tion/jda/api/events/user/UserActivityStartEvent.java index 37b60d7d51..52ea6668f2 100644 --- a/src/main/java/net/dv8tion/jda/api/events/user/UserActivityStartEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/user/UserActivityStartEvent.java @@ -20,7 +20,10 @@ import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; import net.dv8tion.jda.api.events.user.update.GenericUserPresenceEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -50,6 +53,8 @@ *

This also requires {@link net.dv8tion.jda.api.utils.cache.CacheFlag#ACTIVITY CacheFlag.ACTIVITY} to be enabled. * You can enable the cache flag with {@link net.dv8tion.jda.api.JDABuilder#enableCache(CacheFlag, CacheFlag...) enableCache(CacheFlag.ACTIVITY)}. */ +@Requirements(intents = GatewayIntent.GUILD_PRESENCES, cache = CacheFlag.ACTIVITY) +@RequiresCachedMember public class UserActivityStartEvent extends GenericUserEvent implements GenericUserPresenceEvent { private final Activity newActivity; diff --git a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateActivitiesEvent.java b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateActivitiesEvent.java index 3898d7ec69..bc2f609f9a 100644 --- a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateActivitiesEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateActivitiesEvent.java @@ -20,6 +20,9 @@ import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; +import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; import javax.annotation.Nonnull; @@ -50,6 +53,8 @@ * * @since 4.2.1 */ +@Requirements(intents = GatewayIntent.GUILD_PRESENCES, cache = CacheFlag.ACTIVITY) +@RequiresCachedMember public class UserUpdateActivitiesEvent extends GenericUserUpdateEvent> implements GenericUserPresenceEvent { public static final String IDENTIFIER = "activities"; diff --git a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateOnlineStatusEvent.java b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateOnlineStatusEvent.java index 72da133f05..d94c8a89e1 100644 --- a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateOnlineStatusEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateOnlineStatusEvent.java @@ -22,6 +22,8 @@ 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.events.annotations.Requirements; +import net.dv8tion.jda.api.events.annotations.RequiresCachedMember; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.MemberCachePolicy; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -46,6 +48,8 @@ * 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. */ +@Requirements(intents = GatewayIntent.GUILD_PRESENCES, cache = CacheFlag.ONLINE_STATUS) +@RequiresCachedMember public class UserUpdateOnlineStatusEvent extends GenericUserUpdateEvent implements GenericUserPresenceEvent { public static final String IDENTIFIER = "status"; diff --git a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java index 7047b085f0..cc73bdb96c 100644 --- a/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java +++ b/src/main/java/net/dv8tion/jda/api/utils/cache/CacheFlag.java @@ -22,15 +22,7 @@ import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.events.GenericEvent; -import net.dv8tion.jda.api.events.channel.forum.GenericForumTagEvent; -import net.dv8tion.jda.api.events.emoji.GenericEmojiEvent; -import net.dv8tion.jda.api.events.guild.scheduledevent.GenericScheduledEventGatewayEvent; -import net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent; -import net.dv8tion.jda.api.events.sticker.GenericGuildStickerEvent; -import net.dv8tion.jda.api.events.user.UserActivityEndEvent; -import net.dv8tion.jda.api.events.user.UserActivityStartEvent; -import net.dv8tion.jda.api.events.user.update.UserUpdateActivitiesEvent; -import net.dv8tion.jda.api.events.user.update.UserUpdateOnlineStatusEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.internal.utils.Checks; @@ -38,6 +30,7 @@ import javax.annotation.Nullable; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.EnumSet; /** @@ -188,22 +181,9 @@ public static EnumSet fromEvents(@Nonnull Collection flags = EnumSet.noneOf(CacheFlag.class); for (Class event : events) { - if (GenericForumTagEvent.class.isAssignableFrom(event)) - flags.add(FORUM_TAGS); - else if (GenericEmojiEvent.class.isAssignableFrom(event)) - flags.add(EMOJI); - else if (GenericScheduledEventGatewayEvent.class.isAssignableFrom(event)) - flags.add(SCHEDULED_EVENTS); - else if (GenericGuildVoiceEvent.class.isAssignableFrom(event)) - flags.add(VOICE_STATE); - else if (GenericGuildStickerEvent.class.isAssignableFrom(event)) - flags.add(STICKER); - else if (UserActivityStartEvent.class.isAssignableFrom(event) || UserActivityEndEvent.class.isAssignableFrom(event)) - flags.add(ACTIVITY); - else if (UserUpdateActivitiesEvent.class.isAssignableFrom(event)) - flags.add(ACTIVITY); - else if (UserUpdateOnlineStatusEvent.class.isAssignableFrom(event)) - flags.add(ONLINE_STATUS); + final Requirements requirements = event.getDeclaredAnnotation(Requirements.class); + if (requirements != null) + Collections.addAll(flags, requirements.cache()); } return flags; } diff --git a/src/test/java/net/dv8tion/jda/CacheFlagRequirementsTest.java b/src/test/java/net/dv8tion/jda/CacheFlagRequirementsTest.java index c424efd44f..200ea8a34a 100644 --- a/src/test/java/net/dv8tion/jda/CacheFlagRequirementsTest.java +++ b/src/test/java/net/dv8tion/jda/CacheFlagRequirementsTest.java @@ -18,6 +18,7 @@ import com.github.javaparser.ParseResult; import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.PackageDeclaration; import com.github.javaparser.ast.body.TypeDeclaration; import com.github.javaparser.javadoc.Javadoc; import com.github.javaparser.javadoc.description.JavadocDescription; @@ -25,6 +26,7 @@ import com.github.javaparser.utils.SourceRoot; import net.dv8tion.jda.api.events.Event; import net.dv8tion.jda.api.events.GenericEvent; +import net.dv8tion.jda.api.events.annotations.Requirements; import net.dv8tion.jda.api.events.guild.override.GenericPermissionOverrideEvent; import net.dv8tion.jda.api.events.guild.override.PermissionOverrideCreateEvent; import net.dv8tion.jda.api.events.guild.override.PermissionOverrideDeleteEvent; @@ -40,10 +42,7 @@ import javax.annotation.Nonnull; import java.io.IOException; import java.nio.file.Paths; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -92,6 +91,8 @@ else if (!p.getResult().isPresent()) return p.getResult().isPresent(); }) .map(r -> r.getResult().get()) + // Exclude annotations + .filter(c -> !c.getPackageDeclaration().map(PackageDeclaration::getNameAsString).equals(Optional.of(Requirements.class.getPackage().getName()))) .collect(Collectors.toList()); }