diff --git a/src/main/java/net/dv8tion/jda/api/JDA.java b/src/main/java/net/dv8tion/jda/api/JDA.java index 522a5c2e06..9b2ce6994d 100644 --- a/src/main/java/net/dv8tion/jda/api/JDA.java +++ b/src/main/java/net/dv8tion/jda/api/JDA.java @@ -1862,23 +1862,11 @@ default List getEmojisByName(@Nonnull String name, boolean igno // */ //AuditableRestAction installAuxiliaryCable(int port); - /** - * The {@link net.dv8tion.jda.api.AccountType} of the currently logged in account. - *
Used when determining functions that are restricted based on the type of account. - * - * @return The current AccountType. - */ - @Nonnull - AccountType getAccountType(); - /** * Retrieves the {@link ApplicationInfo ApplicationInfo} for * the application that owns the logged in Bot-Account. *
This contains information about the owner of the currently logged in bot account! * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} - * * @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: {@link ApplicationInfo ApplicationInfo} *
The {@link ApplicationInfo ApplicationInfo} of the bot's application. */ @@ -1931,9 +1919,6 @@ default JDA setRequiredScopes(@Nonnull String... scopes) * The permissions to use in your invite, these can be changed by the link user. *
If no permissions are provided the {@code permissions} parameter is omitted * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} - * * @return A valid OAuth2 invite url for the currently logged in Bot-Account */ @Nonnull @@ -1950,9 +1935,6 @@ default JDA setRequiredScopes(@Nonnull String... scopes) * The permissions to use in your invite, these can be changed by the link user. *
If no permissions are provided the {@code permissions} parameter is omitted * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} - * * @return A valid OAuth2 invite url for the currently logged in Bot-Account */ @Nonnull diff --git a/src/main/java/net/dv8tion/jda/api/JDABuilder.java b/src/main/java/net/dv8tion/jda/api/JDABuilder.java index 6aae036256..b46e676278 100644 --- a/src/main/java/net/dv8tion/jda/api/JDABuilder.java +++ b/src/main/java/net/dv8tion/jda/api/JDABuilder.java @@ -19,8 +19,8 @@ import net.dv8tion.jda.api.audio.factory.IAudioSendFactory; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.events.Event; -import net.dv8tion.jda.api.exceptions.InvalidTokenException; import net.dv8tion.jda.api.events.session.ReadyEvent; +import net.dv8tion.jda.api.exceptions.InvalidTokenException; import net.dv8tion.jda.api.hooks.IEventManager; import net.dv8tion.jda.api.hooks.VoiceDispatchInterceptor; import net.dv8tion.jda.api.requests.GatewayIntent; @@ -803,7 +803,7 @@ public JDABuilder setRequestTimeoutRetry(boolean retryOnTimeout) * Sets the token that will be used by the {@link net.dv8tion.jda.api.JDA} instance to log in when * {@link net.dv8tion.jda.api.JDABuilder#build() build()} is called. * - *

For {@link net.dv8tion.jda.api.AccountType#BOT}
+ *

To get a bot token:
*

    *
  1. Go to your Discord Applications
  2. *
  3. Create or select an already existing application
  4. 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 f61853dc79..3caa8aa4ae 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Guild.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Guild.java @@ -4057,7 +4057,6 @@ default AuditableRestAction modifyMemberRoles(@Nonnull Member member, @Non *
      *
    • If the specified Member is {@code null} or not from the same Guild
    • *
    • If the specified Member already is the Guild owner
    • - *
    • If the specified Member is a bot account ({@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT})
    • *
    * * @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction} 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 f5f01f738f..905286a04f 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java @@ -15,6 +15,7 @@ */ 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.ImageProxy; @@ -92,7 +93,6 @@ public class MessageEmbed implements SerializableData /** * The maximum amount of total visible characters an embed can have - *
    This limit depends on the current {@link net.dv8tion.jda.api.AccountType AccountType} and applies to BOT * * @see net.dv8tion.jda.api.EmbedBuilder#setDescription(CharSequence) * @see net.dv8tion.jda.api.EmbedBuilder#setTitle(String) @@ -103,13 +103,16 @@ public class MessageEmbed implements SerializableData /** * The maximum amount of total visible characters an embed can have - *
    This limit depends on the current {@link net.dv8tion.jda.api.AccountType AccountType} and applies to CLIENT * * @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; protected final Object mutex = new Object(); diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.java index 6109dee571..98a1bb5b3e 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.java @@ -208,8 +208,6 @@ default GuildMessageChannelUnion getParentMessageChannel() *
    The request was attempted after the parent channel was deleted. * * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException * If this is a {@link GuildMessageChannel GuildMessageChannel} and the logged in account does not have *
      diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/MessageChannel.java b/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/MessageChannel.java index da2e90cb94..f8aed82be3 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/MessageChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/channel/middleman/MessageChannel.java @@ -15,7 +15,6 @@ */ package net.dv8tion.jda.api.entities.channel.middleman; -import net.dv8tion.jda.api.AccountType; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.MessageEmbed; @@ -25,7 +24,6 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; import net.dv8tion.jda.api.entities.emoji.Emoji; -import net.dv8tion.jda.api.exceptions.AccountTypeException; import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.interactions.components.LayoutComponent; import net.dv8tion.jda.api.interactions.components.buttons.Button; @@ -754,8 +752,6 @@ default MessageCreateAction sendFiles(@Nonnull FileUpload... files) * @param messageId * The id of the sought after Message * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} * @throws IllegalArgumentException * if the provided {@code messageId} is null or empty. * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException @@ -772,7 +768,6 @@ default MessageCreateAction sendFiles(@Nonnull FileUpload... files) @CheckReturnValue default RestAction retrieveMessageById(@Nonnull String messageId) { - AccountTypeException.check(getJDA().getAccountType(), AccountType.BOT); Checks.isSnowflake(messageId, "Message ID"); JDAImpl jda = (JDAImpl) getJDA(); @@ -810,8 +805,6 @@ default RestAction retrieveMessageById(@Nonnull String messageId) * @param messageId * The id of the sought after Message * - * @throws net.dv8tion.jda.api.exceptions.AccountTypeException - * If the currently logged in account is not from {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} * @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException * If this is a {@link GuildMessageChannel GuildMessageChannel} and the logged in account does not have *
        diff --git a/src/main/java/net/dv8tion/jda/api/exceptions/AccountTypeException.java b/src/main/java/net/dv8tion/jda/api/exceptions/AccountTypeException.java deleted file mode 100644 index bd8fa43e3a..0000000000 --- a/src/main/java/net/dv8tion/jda/api/exceptions/AccountTypeException.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.exceptions; - -import net.dv8tion.jda.api.AccountType; - -/** - * Indicates that an operation is not possible unless the {@link net.dv8tion.jda.api.AccountType AccountType} - * matches the one provided in {@link #getRequiredType()} - */ -public class AccountTypeException extends RuntimeException -{ - private final AccountType requiredType; - - /** - * Creates a new AccountTypeException instance - * - * @param requiredType - * The required {@link net.dv8tion.jda.api.AccountType AccountType} for the operation - */ - public AccountTypeException(AccountType requiredType) - { - this(requiredType, "The current AccountType is not valid for the attempted action. Required AccountType: " + requiredType); - } - - /** - * Creates a new AccountTypeException instance - * - * @param requiredType - * The required {@link net.dv8tion.jda.api.AccountType AccountType} for the operation - * @param message - * A specialized message - */ - public AccountTypeException(AccountType requiredType, String message) - { - super(message); - this.requiredType = requiredType; - } - - /** - * The required {@link net.dv8tion.jda.api.AccountType AccountType} for the operation - * - * @return AccountType - */ - public AccountType getRequiredType() - { - return requiredType; - } - - public static void check(AccountType actualType, AccountType requiredType) - { - if (actualType != requiredType) - throw new AccountTypeException(requiredType); - } -} diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java index 56861c48dc..f595ffa49c 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.java @@ -28,7 +28,7 @@ import java.util.function.BooleanSupplier; /** - * Extension of RestAction to allow setting a reason, only available to accounts of {@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT} + * Extension of RestAction to allow setting a reason. * *

        This will automatically use the {@link net.dv8tion.jda.api.audit.ThreadLocalReason ThreadLocalReason} if no * reason was specified via {@link #reason(String)}. diff --git a/src/main/java/net/dv8tion/jda/api/utils/SessionControllerAdapter.java b/src/main/java/net/dv8tion/jda/api/utils/SessionControllerAdapter.java index 46c64d86fb..daf892a94d 100644 --- a/src/main/java/net/dv8tion/jda/api/utils/SessionControllerAdapter.java +++ b/src/main/java/net/dv8tion/jda/api/utils/SessionControllerAdapter.java @@ -17,9 +17,7 @@ package net.dv8tion.jda.api.utils; import com.neovisionaries.ws.client.OpeningHandshakeException; -import net.dv8tion.jda.api.AccountType; import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.exceptions.AccountTypeException; import net.dv8tion.jda.api.exceptions.InvalidTokenException; import net.dv8tion.jda.api.requests.Request; import net.dv8tion.jda.api.requests.Response; @@ -80,7 +78,6 @@ public void setGlobalRatelimit(long ratelimit) @Override public ShardedGateway getShardedGateway(@Nonnull JDA api) { - AccountTypeException.check(api.getAccountType(), AccountType.BOT); return new RestActionImpl(api, Route.Misc.GATEWAY_BOT.compile()) { @Override diff --git a/src/main/java/net/dv8tion/jda/internal/JDAImpl.java b/src/main/java/net/dv8tion/jda/internal/JDAImpl.java index d42108ffe0..88e37cbca4 100644 --- a/src/main/java/net/dv8tion/jda/internal/JDAImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/JDAImpl.java @@ -18,7 +18,6 @@ import com.neovisionaries.ws.client.WebSocketFactory; import gnu.trove.set.TLongSet; -import net.dv8tion.jda.api.AccountType; import net.dv8tion.jda.api.GatewayEncoding; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; @@ -36,7 +35,6 @@ import net.dv8tion.jda.api.events.GenericEvent; import net.dv8tion.jda.api.events.StatusChangeEvent; import net.dv8tion.jda.api.events.session.ShutdownEvent; -import net.dv8tion.jda.api.exceptions.AccountTypeException; import net.dv8tion.jda.api.exceptions.InvalidTokenException; import net.dv8tion.jda.api.exceptions.ParsingException; import net.dv8tion.jda.api.exceptions.RateLimitedException; @@ -945,13 +943,6 @@ public IEventManager getEventManager() return eventManager.getSubject(); } - @Nonnull - @Override - public AccountType getAccountType() - { - return authConfig.getAccountType(); - } - @Override public void setEventManager(IEventManager eventManager) { @@ -1125,7 +1116,6 @@ public RestAction retrieveWebhookById(@Nonnull String webhookId) @Override public RestAction retrieveApplicationInfo() { - AccountTypeException.check(getAccountType(), AccountType.BOT); Route.CompiledRoute route = Route.Applications.GET_BOT_APPLICATION.compile(); return new RestActionImpl<>(this, route, (response, request) -> { diff --git a/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java b/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java index dcc5726e4f..b3b4237da3 100644 --- a/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java +++ b/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java @@ -19,7 +19,10 @@ import com.neovisionaries.ws.client.*; import gnu.trove.iterator.TLongObjectIterator; import gnu.trove.map.TLongObjectMap; -import net.dv8tion.jda.api.*; +import net.dv8tion.jda.api.GatewayEncoding; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.JDAInfo; +import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.audio.hooks.ConnectionListener; import net.dv8tion.jda.api.audio.hooks.ConnectionStatus; import net.dv8tion.jda.api.entities.Guild; @@ -817,9 +820,8 @@ protected void updateAudioManagerReferences() protected String getToken() { - if (api.getAccountType() == AccountType.BOT) - return api.getToken().substring("Bot ".length()); - return api.getToken(); + // all bot tokens are prefixed with "Bot " + return api.getToken().substring("Bot ".length()); } protected List convertPresencesReplace(long responseTotal, DataArray array) diff --git a/src/main/java/net/dv8tion/jda/internal/utils/config/AuthorizationConfig.java b/src/main/java/net/dv8tion/jda/internal/utils/config/AuthorizationConfig.java index e980488e7f..45ddf2b1c6 100644 --- a/src/main/java/net/dv8tion/jda/internal/utils/config/AuthorizationConfig.java +++ b/src/main/java/net/dv8tion/jda/internal/utils/config/AuthorizationConfig.java @@ -16,7 +16,6 @@ package net.dv8tion.jda.internal.utils.config; -import net.dv8tion.jda.api.AccountType; import net.dv8tion.jda.internal.utils.Checks; import javax.annotation.Nonnull; @@ -32,12 +31,6 @@ public AuthorizationConfig(@Nonnull String token) setToken(token); } - @Nonnull - public AccountType getAccountType() - { - return AccountType.BOT; - } - @Nonnull public String getToken() {