From 4b134a4c55ac263177e796a18006697f5f222f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Spie=C3=9F?= Date: Sun, 16 Jun 2024 13:04:19 +0200 Subject: [PATCH] Update and remove deprecated symbols --- src/main/java/net/dv8tion/jda/api/JDA.java | 16 +- .../java/net/dv8tion/jda/api/JDABuilder.java | 90 +----- .../api/audio/hooks/ConnectionListener.java | 109 +------ .../jda/api/audio/hooks/ListenerProxy.java | 23 -- .../dv8tion/jda/api/audit/AuditLogKey.java | 16 - .../net/dv8tion/jda/api/entities/Guild.java | 12 - .../net/dv8tion/jda/api/entities/Member.java | 47 --- .../net/dv8tion/jda/api/entities/Message.java | 279 +----------------- .../jda/api/entities/MessageEmbed.java | 15 - .../jda/api/entities/StageInstance.java | 11 - .../net/dv8tion/jda/api/entities/User.java | 22 +- .../self/SelfUpdateDiscriminatorEvent.java | 7 - .../update/UserUpdateDiscriminatorEvent.java | 7 - .../jda/api/hooks/ListenerAdapter.java | 9 +- .../jda/api/interactions/modals/Modal.java | 91 ------ .../jda/api/managers/AccountManager.java | 15 +- .../jda/api/managers/AudioManager.java | 22 -- .../jda/api/requests/GatewayIntent.java | 11 - .../jda/api/requests/RestRateLimiter.java | 14 - .../sharding/DefaultShardManagerBuilder.java | 124 +------- .../jda/api/utils/SessionController.java | 99 +------ .../jda/internal/entities/UserImpl.java | 2 +- .../internal/handle/UserUpdateHandler.java | 11 + .../internal/managers/AccountManagerImpl.java | 7 - .../EventConsistencyComplianceTest.java | 5 +- 25 files changed, 40 insertions(+), 1024 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/api/JDA.java b/src/main/java/net/dv8tion/jda/api/JDA.java index e5fb70beeea..c4feeb5ba0e 100644 --- a/src/main/java/net/dv8tion/jda/api/JDA.java +++ b/src/main/java/net/dv8tion/jda/api/JDA.java @@ -1026,6 +1026,8 @@ default User getUserById(long id) * *

This will only check cached users! * + *

To check users without discriminators, use {@code username#0000} instead. + * * @param tag * The Discord Tag in the format {@code Username#Discriminator} * @@ -1035,7 +1037,6 @@ default User getUserById(long id) * @return The {@link net.dv8tion.jda.api.entities.User} for the discord tag or null if no user has the provided tag */ @Nullable - @Incubating default User getUserByTag(@Nonnull String tag) { Checks.notNull(tag, "Tag"); @@ -1069,16 +1070,13 @@ default User getUserByTag(@Nonnull String tag) * @return The {@link net.dv8tion.jda.api.entities.User} for the discord tag or null if no user has the provided tag */ @Nullable - @Incubating - default User getUserByTag(@Nonnull String username, @Nonnull String discriminator) + default User getUserByTag(@Nonnull String username, @Nullable String discriminator) { - Checks.notNull(username, "Username"); - Checks.notNull(discriminator, "Discriminator"); - Checks.check(discriminator.length() == 4 && Helpers.isNumeric(discriminator), "Invalid format for discriminator!"); - int codePointLength = Helpers.codePointLength(username); - Checks.check(codePointLength >= 2 && codePointLength <= 32, "Username must be between 2 and 32 codepoints in length!"); + Checks.inRange(username, 2, 32, "Username"); + Checks.check(discriminator == null || discriminator.length() == 4 && Helpers.isNumeric(discriminator), "Invalid format for discriminator! Provided: %s", discriminator); + String actualDiscriminator = discriminator == null ? "0000" : discriminator; return getUserCache().applyStream(stream -> - stream.filter(it -> it.getDiscriminator().equals(discriminator)) + stream.filter(it -> it.getDiscriminator().equals(actualDiscriminator)) .filter(it -> it.getName().equals(username)) .findFirst() .orElse(null) diff --git a/src/main/java/net/dv8tion/jda/api/JDABuilder.java b/src/main/java/net/dv8tion/jda/api/JDABuilder.java index 170ee796077..deceb438709 100644 --- a/src/main/java/net/dv8tion/jda/api/JDABuilder.java +++ b/src/main/java/net/dv8tion/jda/api/JDABuilder.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api; import com.neovisionaries.ws.client.WebSocketFactory; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.audio.factory.IAudioSendFactory; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.events.Event; @@ -547,32 +545,6 @@ public JDABuilder setEventPassthrough(boolean enable) return setFlag(ConfigFlag.EVENT_PASSTHROUGH, enable); } - /** - * Whether the rate-limit should be relative to the current time plus latency. - *
By default we use the {@code X-RateLimit-Reset-After} header to determine when - * a rate-limit is no longer imminent. This has the disadvantage that it might wait longer than needed due - * to the latency which is ignored by the reset-after relative delay. - * - *

When disabled, we will use the {@code X-RateLimit-Reset} absolute timestamp instead which accounts for - * latency but requires a properly NTP synchronized clock to be present. - * If your system does have this feature you might gain a little quicker rate-limit handling than the default allows. - * - *

Default: true - * - * @param enable - * True, if the relative {@code X-RateLimit-Reset-After} header should be used. - * - * @return The JDABuilder instance. Useful for chaining. - */ - @Nonnull - @Deprecated - @ForRemoval(deadline = "5.1.0") - @ReplaceWith("setRestConfig(new RestConfig().setRelativeRateLimit(enable))") - public JDABuilder setRelativeRateLimit(boolean enable) - { - return setFlag(ConfigFlag.USE_RELATIVE_RATELIMIT, enable); - } - /** * Custom {@link RestConfig} to use for this JDA instance. *
This can be used to customize how rate-limits are handled and configure a custom http proxy. @@ -903,67 +875,7 @@ public JDABuilder setWebsocketFactory(@Nullable WebSocketFactory factory) * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution * and should be handled carefully. Only change this pool if you know what you're doing. *
This automatically disables the automatic shutdown of the rate-limit pool, you can enable - * it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimitPool(executor, true)} - * - *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. - * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} - * and similar methods. - * - *

Default: {@link ScheduledThreadPoolExecutor} with 5 threads. - * - * @param pool - * The thread-pool to use for rate-limit handling - * - * @return The JDABuilder instance. Useful for chaining. - * - * @deprecated This pool is now split into two pools. - * You should use {@link #setRateLimitScheduler(ScheduledExecutorService)} and {@link #setRateLimitElastic(ExecutorService)} instead. - */ - @Nonnull - @Deprecated - @ReplaceWith("setRateLimitScheduler(pool)") - public JDABuilder setRateLimitPool(@Nullable ScheduledExecutorService pool) - { - return setRateLimitPool(pool, pool == null); - } - - /** - * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in - * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution - * and should be handled carefully. Only change this pool if you know what you're doing. - * - *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. - * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} - * and similar methods. - * - *

Default: {@link ScheduledThreadPoolExecutor} with 5 threads. - * - * @param pool - * The thread-pool to use for rate-limit handling - * @param automaticShutdown - * Whether {@link JDA#shutdown()} should shutdown this pool - * - * @return The JDABuilder instance. Useful for chaining. - * - * @deprecated This pool is now split into two pools. - * You should use {@link #setRateLimitScheduler(ScheduledExecutorService, boolean)} and {@link #setRateLimitElastic(ExecutorService, boolean)} instead. - */ - @Nonnull - @Deprecated - @ReplaceWith("setRateLimitScheduler(pool, automaticShutdown)") - public JDABuilder setRateLimitPool(@Nullable ScheduledExecutorService pool, boolean automaticShutdown) - { - this.rateLimitScheduler = pool; - this.shutdownRateLimitScheduler = automaticShutdown; - return this; - } - - /** - * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in - * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution - * and should be handled carefully. Only change this pool if you know what you're doing. - *
This automatically disables the automatic shutdown of the rate-limit pool, you can enable - * it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimitPool(executor, true)} + * it using {@link #setRateLimitScheduler(ScheduledExecutorService, boolean) setRateLimitScheduler(executor, true)} * *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} diff --git a/src/main/java/net/dv8tion/jda/api/audio/hooks/ConnectionListener.java b/src/main/java/net/dv8tion/jda/api/audio/hooks/ConnectionListener.java index 2c678615708..e76fa4bdff3 100644 --- a/src/main/java/net/dv8tion/jda/api/audio/hooks/ConnectionListener.java +++ b/src/main/java/net/dv8tion/jda/api/audio/hooks/ConnectionListener.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.audio.hooks; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.audio.SpeakingMode; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.UserSnowflake; @@ -38,7 +36,7 @@ public interface ConnectionListener * @param ping * The time, in milliseconds, for round-trip packet travel to discord. */ - void onPing(long ping); + default void onPing(long ping) {} /** * Called when the status of the audio channel changes. Used to track the connection state of the audio connection @@ -47,110 +45,7 @@ public interface ConnectionListener * @param status * The new {@link net.dv8tion.jda.api.audio.hooks.ConnectionStatus ConnectionStatus} of the audio connection. */ - void onStatusChange(@Nonnull ConnectionStatus status); - - /** - * This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops - * talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins - * or stops. This method is brilliant for clients wanting to display that a user is currently talking. - *

- * Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio) - * AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and - * {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are - * fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such - * is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord, - * this is only fired when that stream starts and when it stops. - *
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning - * and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes. - * - * @param user - * Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed. - * @param speaking - * If true, the user has begun transmitting audio. - * - * @deprecated This method no longer represents the actual speaking state of the user. - * Discord does not send updates when a user starts and stops speaking anymore. - * You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode, - * or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking. - */ - @Deprecated - @ForRemoval - @ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet)") - default void onUserSpeaking(@Nonnull User user, boolean speaking) {} - - /** - * This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops - * talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins - * or stops. This method is brilliant for clients wanting to display that a user is currently talking. - *

- * Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio) - * AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and - * {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are - * fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such - * is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord, - * this is only fired when that stream starts and when it stops. - *
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning - * and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes. - * - * @param user - * Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed. - * @param modes - * EnumSet, containing the active speaking modes. - * Empty if the user has stopped transmitting audio. - * - * @see java.util.EnumSet EnumSet - * @see net.dv8tion.jda.api.audio.SpeakingMode SpeakingMode - * - * @deprecated This method no longer represents the actual speaking state of the user. - * Discord does not send updates when a user starts and stops speaking anymore. - * You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode, - * or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking. - */ - @Deprecated - @ForRemoval - @ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet)") - default void onUserSpeaking(@Nonnull User user, @Nonnull EnumSet modes) {} - - - /** - * This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops - * talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins - * or stops. This method is brilliant for clients wanting to display that a user is currently talking. - *

- * Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio) - * AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and - * {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are - * fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such - * is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord, - * this is only fired when that stream starts and when it stops. - *
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning - * and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio) - * AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes. - * - * @param user - * Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed. - * @param speaking - * If true, the user has begun transmitting audio. - * @param soundshare - * If true, the user is using soundshare - * - * @deprecated This method no longer represents the actual speaking state of the user. - * Discord does not send updates when a user starts and stops speaking anymore. - * You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode, - * or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking. - */ - @Deprecated - @ForRemoval - @ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet)") - default void onUserSpeaking(@Nonnull User user, boolean speaking, boolean soundshare) {} + default void onStatusChange(@Nonnull ConnectionStatus status) {} /** * This method is used to listen for users changing their speaking mode. diff --git a/src/main/java/net/dv8tion/jda/api/audio/hooks/ListenerProxy.java b/src/main/java/net/dv8tion/jda/api/audio/hooks/ListenerProxy.java index 3872154b94a..60d88588f39 100644 --- a/src/main/java/net/dv8tion/jda/api/audio/hooks/ListenerProxy.java +++ b/src/main/java/net/dv8tion/jda/api/audio/hooks/ListenerProxy.java @@ -71,29 +71,6 @@ public void onStatusChange(@Nonnull ConnectionStatus status) } } - @Override - public void onUserSpeaking(@Nonnull User user, @Nonnull EnumSet modes) - { - if (listener == null) - return; - ConnectionListener listener = this.listener; - try - { - if (listener != null) - { - listener.onUserSpeaking(user, modes); - listener.onUserSpeaking(user, modes.contains(SpeakingMode.VOICE)); - listener.onUserSpeaking(user, modes.contains(SpeakingMode.VOICE), modes.contains(SpeakingMode.SOUNDSHARE)); - } - } - catch (Throwable t) - { - log.error("The ConnectionListener encountered and uncaught exception", t); - if (t instanceof Error) - throw (Error) t; - } - } - @Override public void onUserSpeakingModeUpdate(@Nonnull UserSnowflake user, @Nonnull EnumSet modes) { diff --git a/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java b/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java index 7b1522aac92..3437a1b2045 100644 --- a/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java +++ b/src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java @@ -16,9 +16,6 @@ package net.dv8tion.jda.api.audit; -import net.dv8tion.jda.annotations.DeprecatedSince; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.automod.AutoModRule; import net.dv8tion.jda.api.entities.automod.AutoModTriggerType; @@ -354,19 +351,6 @@ public enum AuditLogKey */ THREAD_NAME("name"), - /** - * Change of the {@link ISlowmodeChannel#getSlowmode()} value. - * - *

Expected type: Integer - * - * @deprecated Use {@link #CHANNEL_SLOWMODE} instead - */ - @Deprecated - @ForRemoval - @DeprecatedSince("5.0.0") - @ReplaceWith("CHANNEL_SLOWMODE") - THREAD_SLOWMODE("rate_limit_per_user"), - /** * Change of the {@link ThreadChannel#getAutoArchiveDuration() ThreadChannel.getAutoArchiveDuration()} value. * diff --git a/src/main/java/net/dv8tion/jda/api/entities/Guild.java b/src/main/java/net/dv8tion/jda/api/entities/Guild.java index 2e553787eec..1181bc037f7 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Guild.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Guild.java @@ -1214,14 +1214,8 @@ default Member getMemberById(long userId) * @return The {@link net.dv8tion.jda.api.entities.Member} for the discord tag or null if no member has the provided tag * * @see net.dv8tion.jda.api.JDA#getUserByTag(String) - * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. */ @Nullable - @Deprecated - @ForRemoval default Member getMemberByTag(@Nonnull String tag) { User user = getJDA().getUserByTag(tag); @@ -1254,14 +1248,8 @@ default Member getMemberByTag(@Nonnull String tag) * @return The {@link net.dv8tion.jda.api.entities.Member} for the discord tag or null if no member has the provided tag * * @see #getMemberByTag(String) - * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. */ @Nullable - @Deprecated - @ForRemoval default Member getMemberByTag(@Nonnull String username, @Nonnull String discriminator) { User user = getJDA().getUserByTag(username, discriminator); diff --git a/src/main/java/net/dv8tion/jda/api/entities/Member.java b/src/main/java/net/dv8tion/jda/api/entities/Member.java index 3411c2d32c6..4106f616a29 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Member.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Member.java @@ -16,10 +16,7 @@ package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.annotations.DeprecatedSince; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.annotations.Incubating; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.Permission; @@ -553,50 +550,6 @@ default AuditableRestAction kick() return getGuild().kick(this); } - /** - * Kicks this Member from the {@link net.dv8tion.jda.api.entities.Guild Guild}. - * - *

Note: {@link net.dv8tion.jda.api.entities.Guild#getMembers()} will still contain the {@link net.dv8tion.jda.api.entities.Member Member} - * until Discord sends the {@link net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent GuildMemberRemoveEvent}. - * - *

Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by - * the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following: - *

- * - * @param reason - * The reason for this action or {@code null} if there is no specified reason - * - * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException - * If the logged in account does not have the {@link Permission#KICK_MEMBERS} permission. - * @throws net.dv8tion.jda.api.exceptions.HierarchyException - * If the logged in account cannot kick the other member due to permission hierarchy position. - *
See {@link Member#canInteract(Member)} - * @throws java.lang.IllegalArgumentException - * If the provided reason is longer than 512 characters - * - * @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction} - * Kicks the provided Member from the current Guild - * - * @deprecated - * Use {@link #kick()} and {@link AuditableRestAction#reason(String)} instead - */ - @Nonnull - @CheckReturnValue - @Deprecated - @ForRemoval - @ReplaceWith("kick().reason(reason)") - @DeprecatedSince("5.0.0") - default AuditableRestAction kick(@Nullable String reason) - { - return getGuild().kick(this, reason); - } - /** * Puts this Member in time out in this {@link net.dv8tion.jda.api.entities.Guild Guild} for a specific amount of time. *
While a Member is in time out, all permissions except {@link Permission#VIEW_CHANNEL VIEW_CHANNEL} and diff --git a/src/main/java/net/dv8tion/jda/api/entities/Message.java b/src/main/java/net/dv8tion/jda/api/entities/Message.java index f6251c52f94..9273cf69fd6 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Message.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Message.java @@ -15,8 +15,6 @@ */ package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.channel.Channel; @@ -36,7 +34,6 @@ import net.dv8tion.jda.api.entities.sticker.Sticker; import net.dv8tion.jda.api.entities.sticker.StickerItem; import net.dv8tion.jda.api.entities.sticker.StickerSnowflake; -import net.dv8tion.jda.api.exceptions.HttpException; import net.dv8tion.jda.api.exceptions.InsufficientPermissionException; import net.dv8tion.jda.api.exceptions.MissingAccessException; import net.dv8tion.jda.api.interactions.InteractionType; @@ -44,7 +41,6 @@ import net.dv8tion.jda.api.interactions.components.LayoutComponent; import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.requests.RestAction; -import net.dv8tion.jda.api.requests.RestConfig; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; import net.dv8tion.jda.api.requests.restaction.MessageEditAction; @@ -61,23 +57,19 @@ import net.dv8tion.jda.api.utils.messages.MessageRequest; import net.dv8tion.jda.internal.JDAImpl; import net.dv8tion.jda.internal.entities.ReceivedMessage; -import net.dv8tion.jda.internal.requests.FunctionalCallback; import net.dv8tion.jda.internal.requests.restaction.pagination.PollVotersPaginationActionImpl; import net.dv8tion.jda.internal.utils.Checks; import net.dv8tion.jda.internal.utils.Helpers; -import net.dv8tion.jda.internal.utils.IOUtil; import okhttp3.MultipartBody; -import okhttp3.OkHttpClient; -import okhttp3.Request; import org.jetbrains.annotations.Unmodifiable; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.io.*; +import java.io.File; +import java.io.InputStream; import java.time.OffsetDateTime; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -153,16 +145,6 @@ public interface Message extends ISnowflake, Formattable */ int MAX_FILE_SIZE = 25 << 20; - /** - * The maximum sendable file size for nitro (50 MiB) - * - * @see MessageRequest#setFiles(Collection) - * - * @deprecated Self-bots are not supported anymore and the value is outdated. - */ - @Deprecated - int MAX_FILE_SIZE_NITRO = 50 << 20; - /** * The maximum amount of files sendable within a single message ({@value}) * @@ -2660,263 +2642,6 @@ public String getDescription() return description; } - /** - * Enqueues a request to retrieve the contents of this Attachment. - *
The receiver is expected to close the retrieved {@link java.io.InputStream}. - * - *

Example
- *

{@code
-         * public void printContents(Message.Attachment attachment)
-         * {
-         *     attachment.retrieveInputStream().thenAccept(in -> {
-         *         StringBuilder builder = new StringBuilder();
-         *         byte[] buf = byte[1024];
-         *         int count = 0;
-         *         while ((count = in.read(buf)) > 0)
-         *         {
-         *             builder.append(new String(buf, 0, count));
-         *         }
-         *         in.close();
-         *         System.out.println(builder);
-         *     }).exceptionally(t -> { // handle failure
-         *         t.printStackTrace();
-         *         return null;
-         *     });
-         * }
-         * }
- * - * @return {@link java.util.concurrent.CompletableFuture} - Type: {@link java.io.InputStream} - * - * @deprecated Replaced by {@link #getProxy}, see {@link AttachmentProxy#download()} - */ - @Nonnull - @Deprecated - @ForRemoval - @ReplaceWith("getProxy().download()") - public CompletableFuture retrieveInputStream() // it is expected that the response is closed by the callback! - { - CompletableFuture future = new CompletableFuture<>(); - Request req = getRequest(); - OkHttpClient httpClient = getJDA().getHttpClient(); - httpClient.newCall(req).enqueue(FunctionalCallback - .onFailure((call, e) -> future.completeExceptionally(new UncheckedIOException(e))) - .onSuccess((call, response) -> { - if (response.isSuccessful()) - { - InputStream body = IOUtil.getBody(response); - if (!future.complete(body)) - IOUtil.silentClose(response); - } - else - { - future.completeExceptionally(new HttpException(response.code() + ": " + response.message())); - IOUtil.silentClose(response); - } - }).build()); - return future; - } - - /** - * Downloads the attachment into the current working directory using the file name provided by {@link #getFileName()}. - *
This will download the file using the {@link net.dv8tion.jda.api.JDA#getCallbackPool() callback pool}. - * Alternatively you can use {@link #retrieveInputStream()} and use a continuation with a different executor. - * - *

Example
- *

{@code
-         * public void saveLocally(Message.Attachment attachment)
-         * {
-         *     attachment.downloadToFile()
-         *         .thenAccept(file -> System.out.println("Saved attachment to " + file.getName()))
-         *         .exceptionally(t ->
-         *         { // handle failure
-         *             t.printStackTrace();
-         *             return null;
-         *         });
-         * }
-         * }
- * - * @return {@link java.util.concurrent.CompletableFuture} - Type: {@link java.io.File} - * - * @deprecated Replaced by {@link #getProxy}, see {@link AttachmentProxy#downloadToFile(File)} - */ - @Nonnull - @Deprecated - @ForRemoval - @ReplaceWith("getProxy().downloadToFile()") - public CompletableFuture downloadToFile() // using relative path - { - return downloadToFile(getFileName()); - } - - /** - * Downloads the attachment to a file at the specified path (relative or absolute). - *
This will download the file using the {@link net.dv8tion.jda.api.JDA#getCallbackPool() callback pool}. - * Alternatively you can use {@link #retrieveInputStream()} and use a continuation with a different executor. - * - *

Example
- *

{@code
-         * public void saveLocally(Message.Attachment attachment)
-         * {
-         *     attachment.downloadToFile("/tmp/" + attachment.getFileName())
-         *         .thenAccept(file -> System.out.println("Saved attachment to " + file.getName()))
-         *         .exceptionally(t ->
-         *         { // handle failure
-         *             t.printStackTrace();
-         *             return null;
-         *         });
-         * }
-         * }
- * - * @param path - * The path to save the file to - * - * @throws java.lang.IllegalArgumentException - * If the provided path is null - * - * @return {@link java.util.concurrent.CompletableFuture} - Type: {@link java.io.File} - * - * @deprecated Replaced by {@link #getProxy}, see {@link AttachmentProxy#downloadToFile(File)} - */ - @Nonnull - @Deprecated - @ForRemoval - @ReplaceWith("getProxy().downloadToFile(new File(String))") - public CompletableFuture downloadToFile(String path) - { - Checks.notNull(path, "Path"); - return downloadToFile(new File(path)); - } - - /** - * Downloads the attachment to a file at the specified path (relative or absolute). - *
This will download the file using the {@link net.dv8tion.jda.api.JDA#getCallbackPool() callback pool}. - * Alternatively you can use {@link #retrieveInputStream()} and use a continuation with a different executor. - * - *

Example
- *

{@code
-         * public void saveLocally(Message.Attachment attachment)
-         * {
-         *     attachment.downloadToFile(new File("/tmp/" + attachment.getFileName()))
-         *         .thenAccept(file -> System.out.println("Saved attachment to " + file.getName()))
-         *         .exceptionally(t ->
-         *         { // handle failure
-         *             t.printStackTrace();
-         *             return null;
-         *         });
-         * }
-         * }
- * - * @param file - * The file to write to - * - * @throws java.lang.IllegalArgumentException - * If the provided file is null or cannot be written to - * - * @return {@link java.util.concurrent.CompletableFuture} - Type: {@link java.io.File} - * - * @deprecated Replaced by {@link #getProxy}, see {@link AttachmentProxy#downloadToFile(File)} - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - @Nonnull - @ForRemoval - @ReplaceWith("getProxy().downloadToFile(File)") - public CompletableFuture downloadToFile(File file) - { - Checks.notNull(file, "File"); - try - { - if (!file.exists()) - file.createNewFile(); - else - Checks.check(file.canWrite(), "Cannot write to file %s", file.getName()); - } - catch (IOException e) - { - throw new IllegalArgumentException("Cannot create file", e); - } - - return retrieveInputStream().thenApplyAsync((stream) -> { - try (FileOutputStream out = new FileOutputStream(file)) - { - byte[] buf = new byte[1024]; - int count; - while ((count = stream.read(buf)) > 0) - { - out.write(buf, 0, count); - } - return file; - } - catch (IOException e) - { - throw new UncheckedIOException(e); - } - finally - { - IOUtil.silentClose(stream); - } - }, getJDA().getCallbackPool()); - } - - /** - * Retrieves the image of this attachment and provides an {@link net.dv8tion.jda.api.entities.Icon} equivalent. - *
Useful with {@link net.dv8tion.jda.api.managers.AccountManager#setAvatar(Icon)}. - *
This will download the file using the {@link net.dv8tion.jda.api.JDA#getCallbackPool() callback pool}. - * Alternatively you can use {@link #retrieveInputStream()} and use a continuation with a different executor. - * - *

Example
- *

{@code
-         * public void changeAvatar(Message.Attachment attachment)
-         * {
-         *     attachment.retrieveAsIcon().thenCompose(icon -> {
-         *         SelfUser self = attachment.getJDA().getSelfUser();
-         *         AccountManager manager = self.getManager();
-         *         return manager.setAvatar(icon).submit();
-         *     }).exceptionally(t -> {
-         *         t.printStackTrace();
-         *         return null;
-         *     });
-         * }
-         * }
- * - * @throws java.lang.IllegalStateException - * If this is not an image ({@link #isImage()}) - * - * @return {@link java.util.concurrent.CompletableFuture} - Type: {@link net.dv8tion.jda.api.entities.Icon} - * - * @deprecated Replaced by {@link #getProxy}, see {@link AttachmentProxy#downloadAsIcon()} - */ - @Nonnull - @ReplaceWith("getProxy().downloadAsIcon()") - public CompletableFuture retrieveAsIcon() - { - if (!isImage()) - throw new IllegalStateException("Cannot create an Icon out of this attachment. This is not an image."); - return retrieveInputStream().thenApplyAsync((stream) -> - { - try - { - return Icon.from(stream); - } - catch (IOException e) - { - throw new UncheckedIOException(e); - } - finally - { - IOUtil.silentClose(stream); - } - }, getJDA().getCallbackPool()); - } - - protected Request getRequest() - { - return new Request.Builder() - .url(getUrl()) - .addHeader("user-agent", RestConfig.USER_AGENT) - .addHeader("accept-encoding", "gzip, deflate") - .build(); - } - /** * The size of the attachment in bytes. *
Example: if {@code getSize()} returns 1024, then the attachment is 1024 bytes, or 1KiB, in size. diff --git a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java index b5b2efb4c45..03a17404a78 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java @@ -15,7 +15,6 @@ */ package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.utils.AttachmentProxy; import net.dv8tion.jda.api.utils.FileProxy; @@ -103,20 +102,6 @@ public class MessageEmbed implements SerializableData */ public static final int EMBED_MAX_LENGTH_BOT = 6000; - /** - * The maximum amount of total visible characters an embed can have - * - * @see net.dv8tion.jda.api.EmbedBuilder#setDescription(CharSequence) - * @see net.dv8tion.jda.api.EmbedBuilder#setTitle(String) - * @see net.dv8tion.jda.api.EmbedBuilder#setFooter(String, String) - * @see net.dv8tion.jda.api.EmbedBuilder#addField(String, String, boolean) - * - * @deprecated This will be removed in the future. - */ - @Deprecated - @ForRemoval - public static final int EMBED_MAX_LENGTH_CLIENT = 2000; - /** * The maximum amount of total embed fields the embed can hold * diff --git a/src/main/java/net/dv8tion/jda/api/entities/StageInstance.java b/src/main/java/net/dv8tion/jda/api/entities/StageInstance.java index 7257153a323..3aeb5ef624f 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/StageInstance.java +++ b/src/main/java/net/dv8tion/jda/api/entities/StageInstance.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.annotations.DeprecatedSince; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.entities.channel.concrete.StageChannel; import net.dv8tion.jda.api.managers.StageInstanceManager; import net.dv8tion.jda.api.requests.RestAction; @@ -155,15 +153,6 @@ enum PrivacyLevel { /** Placeholder for future privacy levels, indicates that this version of JDA does not support this privacy level yet */ UNKNOWN(-1), - /** - * This stage instance can be accessed by lurkers, meaning users that are not active members of the guild - * - * @deprecated Public stage instances are no longer supported by discord - */ - @Deprecated - @ForRemoval - @DeprecatedSince("5.0.0") - PUBLIC(1), /** This stage instance can only be accessed by guild members */ GUILD_ONLY(2); diff --git a/src/main/java/net/dv8tion/jda/api/entities/User.java b/src/main/java/net/dv8tion/jda/api/entities/User.java index d272213eeba..45dbbf874d8 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/User.java +++ b/src/main/java/net/dv8tion/jda/api/entities/User.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel; import net.dv8tion.jda.api.requests.restaction.CacheRestAction; @@ -164,18 +162,15 @@ default String getEffectiveName() } /** - *
The discriminator of the {@link net.dv8tion.jda.api.entities.User User}. Used to differentiate between users with the same usernames. + * The discriminator of the {@link net.dv8tion.jda.api.entities.User User}. Used to differentiate between users with the same usernames. *
This only contains the 4 digits after the username and the #. * - * @return Never-null String containing the {@link net.dv8tion.jda.api.entities.User User} discriminator. + *

For most users, no discriminator is used and this will be {@code "0000"} instead. + * The primary use-case for discriminators is bot and guest accounts, to prevent name squatting. * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. + * @return Never-null String containing the {@link net.dv8tion.jda.api.entities.User User} discriminator. */ @Nonnull - @Deprecated - @ForRemoval String getDiscriminator(); /** @@ -257,16 +252,11 @@ default ImageProxy getEffectiveAvatar() * The "tag" for this user *

This is the equivalent of calling {@link java.lang.String#format(String, Object...) String.format}("%#s", user) * - * @return Never-null String containing the tag for this user, for example DV8FromTheWorld#6297 + *

Users without a discriminator use {@code #0000} instead. * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. + * @return Never-null String containing the tag for this user, for example DV8FromTheWorld#6297 */ @Nonnull - @Deprecated - @ForRemoval - @ReplaceWith("getName()") String getAsTag(); /** diff --git a/src/main/java/net/dv8tion/jda/api/events/self/SelfUpdateDiscriminatorEvent.java b/src/main/java/net/dv8tion/jda/api/events/self/SelfUpdateDiscriminatorEvent.java index cc35f771f78..a2fbd410ef0 100644 --- a/src/main/java/net/dv8tion/jda/api/events/self/SelfUpdateDiscriminatorEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/self/SelfUpdateDiscriminatorEvent.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.api.events.self; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.JDA; import javax.annotation.Nonnull; @@ -27,13 +26,7 @@ *

Can be used to retrieve the old discriminator. * *

Identifier: {@code discriminator} - * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. */ -@Deprecated -@ForRemoval public class SelfUpdateDiscriminatorEvent extends GenericSelfUpdateEvent { public static final String IDENTIFIER = "discriminator"; diff --git a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.java b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.java index 928e0067c00..7f41a8f7c60 100644 --- a/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.api.events.user.update; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.User; @@ -39,13 +38,7 @@ * 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. - * - * @deprecated This will become obsolete in the future. - * Discriminators are being phased out and replaced by globally unique usernames. - * For more information, see New Usernames & Display Names. */ -@Deprecated -@ForRemoval public class UserUpdateDiscriminatorEvent extends GenericUserUpdateEvent { public static final String IDENTIFIER = "discriminator"; diff --git a/src/main/java/net/dv8tion/jda/api/hooks/ListenerAdapter.java b/src/main/java/net/dv8tion/jda/api/hooks/ListenerAdapter.java index 0ee9eb61605..0c18a59fbbb 100644 --- a/src/main/java/net/dv8tion/jda/api/hooks/ListenerAdapter.java +++ b/src/main/java/net/dv8tion/jda/api/hooks/ListenerAdapter.java @@ -15,8 +15,6 @@ */ package net.dv8tion.jda.api.hooks; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.events.*; import net.dv8tion.jda.api.events.automod.*; import net.dv8tion.jda.api.events.channel.ChannelCreateEvent; @@ -160,8 +158,6 @@ public void onEntitySelectInteraction(@Nonnull EntitySelectInteractionEvent even //User Events public void onUserUpdateName(@Nonnull UserUpdateNameEvent event) {} public void onUserUpdateGlobalName(@Nonnull UserUpdateGlobalNameEvent event) {} - @Deprecated - @ForRemoval public void onUserUpdateDiscriminator(@Nonnull UserUpdateDiscriminatorEvent event) {} public void onUserUpdateAvatar(@Nonnull UserUpdateAvatarEvent event) {} public void onUserUpdateOnlineStatus(@Nonnull UserUpdateOnlineStatusEvent event) {} @@ -176,6 +172,7 @@ public void onUserUpdateActivities(@Nonnull UserUpdateActivitiesEvent event) {} public void onSelfUpdateAvatar(@Nonnull SelfUpdateAvatarEvent event) {} public void onSelfUpdateMFA(@Nonnull SelfUpdateMFAEvent event) {} public void onSelfUpdateName(@Nonnull SelfUpdateNameEvent event) {} + public void onSelfUpdateDiscriminator(@Nonnull SelfUpdateDiscriminatorEvent event) {} public void onSelfUpdateGlobalName(@Nonnull SelfUpdateGlobalNameEvent event) {} public void onSelfUpdateVerified(@Nonnull SelfUpdateVerifiedEvent event) {} @@ -381,10 +378,6 @@ public void onEntitlementDelete(@Nonnull EntitlementDeleteEvent event) {} public void onHttpRequest(@Nonnull HttpRequestEvent event) {} //Generic Events - @Deprecated - @ReplaceWith("onGenericSession(event)") - @ForRemoval(deadline = "5.0.0") - public void onGenericSessionEvent(@Nonnull GenericSessionEvent event) {} public void onGenericSession(@Nonnull GenericSessionEvent event) {} public void onGenericInteractionCreate(@Nonnull GenericInteractionCreateEvent event) {} public void onGenericAutoCompleteInteraction(@Nonnull GenericAutoCompleteInteractionEvent event) {} diff --git a/src/main/java/net/dv8tion/jda/api/interactions/modals/Modal.java b/src/main/java/net/dv8tion/jda/api/interactions/modals/Modal.java index d38b0f28b3c..37bfe953232 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/modals/Modal.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/modals/Modal.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.interactions.modals; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.interactions.components.ItemComponent; @@ -25,8 +23,6 @@ import net.dv8tion.jda.api.utils.data.SerializableData; import net.dv8tion.jda.internal.interactions.modal.ModalImpl; import net.dv8tion.jda.internal.utils.Checks; -import net.dv8tion.jda.internal.utils.Helpers; -import org.jetbrains.annotations.Unmodifiable; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; @@ -107,25 +103,6 @@ public interface Modal extends SerializableData @Nonnull String getTitle(); - /** - * A List of {@link net.dv8tion.jda.api.interactions.components.ActionRow ActionRows} that this modal contains. - * - * @return List of ActionRows - * - * @deprecated Use {@link #getComponents()} instead - */ - @Nonnull - @ForRemoval - @Deprecated - @ReplaceWith("getComponents()") - default List getActionRows() - { - return getComponents().stream() - .filter(ActionRow.class::isInstance) - .map(ActionRow.class::cast) - .collect(Helpers.toUnmodifiableList()); - } - /** * A List of {@link LayoutComponent LayoutComponents} that this modal contains. * @@ -226,56 +203,6 @@ public Builder setTitle(@Nonnull String title) return this; } - /** - * Adds ActionRows to this modal - * - * @param actionRows - * ActionRows to add to the modal, up to 5 - * - * @throws IllegalArgumentException - *

    - *
  • If any of the provided ActionRows are null
  • - *
  • If any of the provided ActionRows' components are not compatible with Modals
  • - *
- * - * @return The same builder instance for chaining - * - * @see ActionRow#isModalCompatible() - */ - @Nonnull - @ForRemoval - @Deprecated - @ReplaceWith("addComponents(actionRows)") - public Builder addActionRows(@Nonnull ActionRow... actionRows) - { - return addComponents(actionRows); - } - - /** - * Adds ActionRows to this modal - * - * @param actionRows - * ActionRows to add to the modal, up to 5 - * - * @throws IllegalArgumentException - *
    - *
  • If any of the provided ActionRows are null
  • - *
  • If any of the provided ActionRows' components are not compatible with Modals
  • - *
- * - * @return The same builder instance for chaining - * - * @see ActionRow#isModalCompatible() - */ - @Nonnull - @ForRemoval - @Deprecated - @ReplaceWith("addComponents(actionRows)") - public Builder addActionRows(@Nonnull Collection actionRows) - { - return addComponents(actionRows); - } - /** * Adds {@link LayoutComponent LayoutComponents} to this modal * @@ -372,24 +299,6 @@ public Builder addActionRow(@Nonnull ItemComponent... components) return addComponents(ActionRow.of(components)); } - /** - * Returns an immutable list of all ActionRow components - * - * @return An immutable list of all ActionRow components - */ - @Nonnull - @ForRemoval - @Deprecated - @ReplaceWith("getComponents()") - @Unmodifiable - public List getActionRows() - { - return components.stream() - .filter(ActionRow.class::isInstance) - .map(ActionRow.class::cast) - .collect(Helpers.toUnmodifiableList()); - } - /** * Returns a modifiable list of all components * diff --git a/src/main/java/net/dv8tion/jda/api/managers/AccountManager.java b/src/main/java/net/dv8tion/jda/api/managers/AccountManager.java index 6c51dd078ec..75a563040a4 100644 --- a/src/main/java/net/dv8tion/jda/api/managers/AccountManager.java +++ b/src/main/java/net/dv8tion/jda/api/managers/AccountManager.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.api.managers; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.api.entities.Icon; import net.dv8tion.jda.api.entities.SelfUser; @@ -42,16 +41,12 @@ public interface AccountManager extends Manager { /** * Used to reset the name field - * - * @deprecated Bot usernames are set through the application name now. */ - @Deprecated - @ForRemoval - long NAME = 1; + long NAME = 1; /** Used to reset the avatar field */ - long AVATAR = 1 << 1; + long AVATAR = 1 << 1; /** Used to reset the banner field */ - long BANNER = 1 << 2; + long BANNER = 1 << 2; /** * The {@link net.dv8tion.jda.api.entities.SelfUser SelfUser} that will be @@ -118,13 +113,9 @@ public interface AccountManager extends Manager * * * @return AccountManager for chaining convenience - * - * @deprecated Bot usernames are set through the application name now. */ @Nonnull @CheckReturnValue - @Deprecated - @ForRemoval AccountManager setName(@Nonnull String name); /** diff --git a/src/main/java/net/dv8tion/jda/api/managers/AudioManager.java b/src/main/java/net/dv8tion/jda/api/managers/AudioManager.java index 8ed6c632356..6016db18898 100644 --- a/src/main/java/net/dv8tion/jda/api/managers/AudioManager.java +++ b/src/main/java/net/dv8tion/jda/api/managers/AudioManager.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.api.managers; -import net.dv8tion.jda.annotations.ForRemoval; import net.dv8tion.jda.annotations.Incubating; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.audio.AudioReceiveHandler; @@ -142,27 +141,6 @@ default void setSpeakingMode(@Nonnull SpeakingMode... mode) @Incubating EnumSet getSpeakingMode(); - /** - * Configures the delay between the last provided frame and removing the speaking indicator. - *
This can be useful for send systems that buffer a certain interval of audio frames that will be sent. - * By default the delay is 200 milliseconds which is also the minimum delay. - * - *

If the delay is less than 200 milliseconds it will use the minimum delay. The provided delay - * will be aligned to the audio frame length of 20 milliseconds by means of integer division. This means - * it will be rounded down to the next biggest multiple of 20. - * - *

Note that this delay is not reliable and operates entirely based on the send system polling times - * which can cause it to be released earlier or later than the provided delay specifies. - * - * @param millis - * The delay that should be used, in milliseconds - * - * @since 4.0.0 - */ - @Deprecated - @ForRemoval - void setSpeakingDelay(int millis); - /** * Gets the {@link net.dv8tion.jda.api.JDA JDA} instance that this AudioManager is a part of. * diff --git a/src/main/java/net/dv8tion/jda/api/requests/GatewayIntent.java b/src/main/java/net/dv8tion/jda/api/requests/GatewayIntent.java index 89814da397f..a2dcaf302e8 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/GatewayIntent.java +++ b/src/main/java/net/dv8tion/jda/api/requests/GatewayIntent.java @@ -16,9 +16,6 @@ package net.dv8tion.jda.api.requests; -import net.dv8tion.jda.annotations.DeprecatedSince; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.GenericEvent; @@ -97,14 +94,6 @@ public enum GatewayIntent *

This will also update user information such as name/avatar. */ GUILD_MEMBERS(1), - /** - * Ban events. - */ - @Deprecated - @ForRemoval - @DeprecatedSince("5.0.0-beta.4") - @ReplaceWith("GUILD_MODERATION") - GUILD_BANS(2), /** * Moderation events, such as ban/unban/audit-log. */ diff --git a/src/main/java/net/dv8tion/jda/api/requests/RestRateLimiter.java b/src/main/java/net/dv8tion/jda/api/requests/RestRateLimiter.java index c87d710a0b6..29e423a837a 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/RestRateLimiter.java +++ b/src/main/java/net/dv8tion/jda/api/requests/RestRateLimiter.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.api.requests; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.JDA; import okhttp3.Response; import org.jetbrains.annotations.Blocking; @@ -268,19 +267,6 @@ public RateLimitConfig(@Nonnull ScheduledExecutorService scheduler, @Nonnull Exe this.isRelative = isRelative; } - /** - * The {@link ScheduledExecutorService} used to schedule rate-limit tasks. - * - * @return The {@link ScheduledExecutorService} - */ - @Nonnull - @Deprecated - @ReplaceWith("getScheduler() or getElastic()") - public ScheduledExecutorService getPool() - { - return scheduler; - } - /** * The {@link ScheduledExecutorService} used to schedule rate-limit tasks. * diff --git a/src/main/java/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.java b/src/main/java/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.java index 02700abd03c..4a97b488946 100644 --- a/src/main/java/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.java +++ b/src/main/java/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.sharding; import com.neovisionaries.ws.client.WebSocketFactory; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.GatewayEncoding; import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.audio.factory.IAudioSendFactory; @@ -559,34 +557,6 @@ public DefaultShardManagerBuilder setEventPassthrough(boolean enable) return setFlag(ConfigFlag.EVENT_PASSTHROUGH, enable); } - /** - * Whether the rate-limit should be relative to the current time plus latency. - *
By default we use the {@code X-RateLimit-Rest-After} header to determine when - * a rate-limit is no longer imminent. This has the disadvantage that it might wait longer than needed due - * to the latency which is ignored by the reset-after relative delay. - * - *

When disabled, we will use the {@code X-RateLimit-Reset} absolute timestamp instead which accounts for - * latency but requires a properly NTP synchronized clock to be present. - * If your system does have this feature you might gain a little quicker rate-limit handling than the default allows. - * - *

Default: true - * - * @param enable - * True, if the relative {@code X-RateLimit-Reset-After} header should be used. - * - * @return The DefaultShardManagerBuilder instance. Useful for chaining. - * - * @since 4.1.0 - */ - @Nonnull - @Deprecated - @ForRemoval(deadline = "5.1.0") - @ReplaceWith("setRestConfig(new RestConfig().setRelativeRateLimit(enable))") - public DefaultShardManagerBuilder setRelativeRateLimit(boolean enable) - { - return setFlag(ConfigFlag.USE_RELATIVE_RATELIMIT, enable); - } - /** * Custom {@link RestConfig} to use. *
This can be used to customize how rate-limits are handled and configure a custom http proxy. @@ -1317,97 +1287,9 @@ public DefaultShardManagerBuilder setHttpClient(@Nullable OkHttpClient client) * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution * and should be handled carefully. Only change this pool if you know what you're doing. - *
This will override the rate-limit pool provider set from {@link #setRateLimitPoolProvider(ThreadPoolProvider)}. - *
This automatically disables the automatic shutdown of the rate-limit pool, you can enable - * it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimiPool(executor, true)} - * - *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. - * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} - * and similar methods. - * - *

Default: Shared {@link ScheduledThreadPoolExecutor} with ({@code 2 * }{@link #setShardsTotal(int) shard_total}) threads. - * - * @param pool - * The thread-pool to use for rate-limit handling - * - * @return The DefaultShardManagerBuilder instance. Useful for chaining. - * - * @deprecated This pool is now split into two pools. - * You should use {@link #setRateLimitScheduler(ScheduledExecutorService)} and {@link #setRateLimitElastic(ExecutorService)} instead. - */ - @Nonnull - @Deprecated - @ReplaceWith("setRateLimitScheduler(pool) or setRateLimitElastic(pool)") - public DefaultShardManagerBuilder setRateLimitPool(@Nullable ScheduledExecutorService pool) - { - return setRateLimitPool(pool, pool == null); - } - - /** - * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in - * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution - * and should be handled carefully. Only change this pool if you know what you're doing. - *
This will override the rate-limit pool provider set from {@link #setRateLimitPoolProvider(ThreadPoolProvider)}. - * - *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. - * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} - * and similar methods. - * - *

Default: Shared {@link ScheduledThreadPoolExecutor} with ({@code 2 * }{@link #setShardsTotal(int) shard_total}) threads. - * - * @param pool - * The thread-pool to use for rate-limit handling - * @param automaticShutdown - * Whether {@link net.dv8tion.jda.api.JDA#shutdown()} should automatically shutdown this pool - * - * @return The DefaultShardManagerBuilder instance. Useful for chaining. - * - * @deprecated This pool is now split into two pools. - * You should use {@link #setRateLimitScheduler(ScheduledExecutorService, boolean)} and {@link #setRateLimitElastic(ExecutorService, boolean)} instead. - */ - @Nonnull - @Deprecated - @ReplaceWith("setRateLimitScheduler(pool, automaticShutdown) or setRateLimitElastic(pool, automaticShutdown)") - public DefaultShardManagerBuilder setRateLimitPool(@Nullable ScheduledExecutorService pool, boolean automaticShutdown) - { - return setRateLimitPoolProvider(pool == null ? null : new ThreadPoolProviderImpl<>(pool, automaticShutdown)); - } - - /** - * Sets the {@link ScheduledExecutorService ScheduledExecutorService} provider that should be used in - * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution - * and should be handled carefully. Only change this pool if you know what you're doing. - * - *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. - * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} - * and similar methods. - * - *

Default: Shared {@link ScheduledThreadPoolExecutor} with ({@code 2 * }{@link #setShardsTotal(int) shard_total}) threads. - * - * @param provider - * The thread-pool provider to use for rate-limit handling - * - * @return The DefaultShardManagerBuilder instance. Useful for chaining. - * - * @deprecated This pool is now split into two pools. - * You should use {@link #setRateLimitPoolProvider(ThreadPoolProvider)} and {@link #setRateLimitElasticProvider(ThreadPoolProvider)} instead. - */ - @Nonnull - @Deprecated - @ReplaceWith("setRateLimitSchedulerProvider(provider) or setRateLimitElasticProvider(provider)") - public DefaultShardManagerBuilder setRateLimitPoolProvider(@Nullable ThreadPoolProvider provider) - { - this.rateLimitSchedulerProvider = provider; - return this; - } - - /** - * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in - * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution - * and should be handled carefully. Only change this pool if you know what you're doing. - *
This will override the rate-limit pool provider set from {@link #setRateLimitPoolProvider(ThreadPoolProvider)}. + *
This will override the rate-limit pool provider set from {@link #setRateLimitSchedulerProvider(ThreadPoolProvider)}. *
This automatically disables the automatic shutdown of the rate-limit pool, you can enable - * it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimiPool(executor, true)} + * it using {@link #setRateLimitScheduler(ScheduledExecutorService, boolean) setRateLimiPool(executor, true)} * *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} @@ -1430,7 +1312,7 @@ public DefaultShardManagerBuilder setRateLimitScheduler(@Nullable ScheduledExecu * Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in * the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution * and should be handled carefully. Only change this pool if you know what you're doing. - *
This will override the rate-limit pool provider set from {@link #setRateLimitPoolProvider(ThreadPoolProvider)}. + *
This will override the rate-limit pool provider set from {@link #setRateLimitSchedulerProvider(ThreadPoolProvider)}. * *

This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions. * Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)} diff --git a/src/main/java/net/dv8tion/jda/api/utils/SessionController.java b/src/main/java/net/dv8tion/jda/api/utils/SessionController.java index 864925ac8b2..d4b9d5e1f53 100644 --- a/src/main/java/net/dv8tion/jda/api/utils/SessionController.java +++ b/src/main/java/net/dv8tion/jda/api/utils/SessionController.java @@ -16,8 +16,6 @@ package net.dv8tion.jda.api.utils; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.requests.RestRateLimiter; @@ -37,8 +35,7 @@ * *

Global REST Ratelimit *
The global REST ratelimit is not bound to a single session and should be - * handled on all JDA instances. This controller will receive updates of this ratelimit through {@link #setGlobalRatelimit(long)} - * and should report the last ratelimit information it received through {@link #getGlobalRatelimit()}. + * handled on all JDA instances. This controller will manage the global ratelimit using {@link #getRateLimitHandle}. * *

Gateway Provider *
This provider can be used to change the gateway retrieval (using cache, http, or static) and @@ -125,34 +122,6 @@ default void setConcurrency(int level) {} */ void removeSession(@Nonnull SessionConnectNode node); - /** - * Provides the cross-session global REST ratelimit it received through {@link #setGlobalRatelimit(long)}. - * - * @return The current global REST ratelimit or -1 if unset - * - * @deprecated Use {@link #getRateLimitHandle()} instead - */ - @Deprecated - @ForRemoval(deadline = "5.0.0") - @ReplaceWith("getRateLimitHandle().getClassic()") - default long getGlobalRatelimit() - { - return -1; - } - - /** - * Called by the RateLimiter if the global rest ratelimit has changed. - * - * @param ratelimit - * The new global ratelimit - * - * @deprecated Use {@link #getRateLimitHandle()} instead - */ - @Deprecated - @ForRemoval(deadline = "5.0.0") - @ReplaceWith("getRateLimitHandle().getClassic()") - default void setGlobalRatelimit(long ratelimit) {} - /** * The store for global rate-limits of all types. *
This can be used to share the global rate-limit information between shards on the same IP. @@ -162,7 +131,7 @@ default void setGlobalRatelimit(long ratelimit) {} @Nonnull default RestRateLimiter.GlobalRateLimit getRateLimitHandle() { - return new GlobalRateLimitAdapter(this); + return RestRateLimiter.GlobalRateLimit.create(); } /** @@ -302,68 +271,4 @@ interface SessionConnectNode */ void run(boolean isLast) throws InterruptedException; } - - /** - * Wrapper for {@link #getGlobalRatelimit()} and {@link #setGlobalRatelimit(long)}. - */ - @Deprecated - @ForRemoval(deadline = "5.0.0") - @ReplaceWith("getRateLimitHandle()") - @SuppressWarnings("DeprecatedIsStillUsed") - class GlobalRateLimitAdapter implements RestRateLimiter.GlobalRateLimit - { - private final SessionController controller; - - public GlobalRateLimitAdapter(@Nonnull SessionController controller) - { - SessionControllerAdapter.log.warn("Using outdated implementation of global rate-limit handling. It is recommended to use GlobalRateLimit interface instead!"); - this.controller = controller; - } - - /** - * Forwarding to {@link SessionController#getGlobalRatelimit()} - * - * @return The current global ratelimit - */ - @Override - public long getClassic() - { - return controller.getGlobalRatelimit(); - } - - /** - * Forwarding to {@link SessionController#setGlobalRatelimit(long)} - * - * @param ratelimit - * The new global ratelimit - */ - @Override - public void setClassic(long ratelimit) - { - controller.setGlobalRatelimit(ratelimit); - } - - /** - * Forwarding to {@link SessionController#getGlobalRatelimit()} - * - * @return The current global ratelimit - */ - @Override - public long getCloudflare() - { - return getClassic(); - } - - /** - * Forwarding to {@link SessionController#setGlobalRatelimit(long)} - * - * @param timestamp - * The new global ratelimit - */ - @Override - public void setCloudflare(long timestamp) - { - setClassic(timestamp); - } - } } diff --git a/src/main/java/net/dv8tion/jda/internal/entities/UserImpl.java b/src/main/java/net/dv8tion/jda/internal/entities/UserImpl.java index eba01e89a0f..783885a82bc 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/UserImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/UserImpl.java @@ -75,7 +75,7 @@ public String getGlobalName() @Override public String getDiscriminator() { - return Helpers.format("%04d", discriminator); + return discriminator == 0 ? "0000" : Helpers.format("%04d", discriminator); } @Nullable diff --git a/src/main/java/net/dv8tion/jda/internal/handle/UserUpdateHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/UserUpdateHandler.java index abd50ea67d5..06b09f782f2 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/UserUpdateHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/UserUpdateHandler.java @@ -36,6 +36,7 @@ protected Long handleInternally(DataObject content) SelfUserImpl self = (SelfUserImpl) getJDA().getSelfUser(); String name = content.getString("username"); + String discriminator = content.getString("discriminator"); String globalName = content.getString("global_name", null); String avatarId = content.getString("avatar", null); Boolean verified = content.hasKey("verified") ? content.getBoolean("verified") : null; @@ -51,6 +52,16 @@ protected Long handleInternally(DataObject content) oldName)); } + if (!Objects.equals(discriminator, self.getDiscriminator())) + { + String oldDiscriminator = self.getDiscriminator(); + self.setDiscriminator(Short.parseShort(discriminator)); + getJDA().handleEvent( + new SelfUpdateDiscriminatorEvent( + getJDA(), responseNumber, + oldDiscriminator)); + } + if (!Objects.equals(globalName, self.getGlobalName())) { String oldGlobalName = self.getGlobalName(); diff --git a/src/main/java/net/dv8tion/jda/internal/managers/AccountManagerImpl.java b/src/main/java/net/dv8tion/jda/internal/managers/AccountManagerImpl.java index 4da6e543d67..2a90ec00be5 100644 --- a/src/main/java/net/dv8tion/jda/internal/managers/AccountManagerImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/managers/AccountManagerImpl.java @@ -90,7 +90,6 @@ public AccountManagerImpl reset() @Nonnull @Override - @Deprecated @CheckReturnValue public AccountManagerImpl setName(@Nonnull String name) { @@ -128,10 +127,6 @@ protected RequestBody finalizeData() { DataObject body = DataObject.empty(); - //Required fields. Populate with current values.. - body.put("username", getSelfUser().getName()); - body.put("avatar", getSelfUser().getAvatarId()); - if (shouldUpdate(NAME)) body.put("username", name); if (shouldUpdate(AVATAR)) @@ -146,8 +141,6 @@ protected RequestBody finalizeData() @Override protected void handleSuccess(Response response, Request request) { -// String newToken = response.getObject().getString("token").replace("Bot ", ""); -// api.setToken(newToken); request.onSuccess(null); } } diff --git a/src/test/java/net/dv8tion/jda/test/compliance/EventConsistencyComplianceTest.java b/src/test/java/net/dv8tion/jda/test/compliance/EventConsistencyComplianceTest.java index 8b246c19b7a..33665d78f5d 100644 --- a/src/test/java/net/dv8tion/jda/test/compliance/EventConsistencyComplianceTest.java +++ b/src/test/java/net/dv8tion/jda/test/compliance/EventConsistencyComplianceTest.java @@ -19,7 +19,6 @@ import net.dv8tion.jda.api.events.Event; import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.UpdateEvent; -import net.dv8tion.jda.api.events.self.SelfUpdateDiscriminatorEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -45,9 +44,7 @@ static void setup() eventTypes = events.getSubTypesOf(GenericEvent.class); excludedTypes = new HashSet<>(Arrays.asList( // Special casing - UpdateEvent.class, Event.class, GenericEvent.class, - // Deprecated / Removed / Unused - SelfUpdateDiscriminatorEvent.class + UpdateEvent.class, Event.class, GenericEvent.class )); }