Skip to content

Commit

Permalink
Remove AccountType (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment authored Apr 2, 2023
1 parent 71e2598 commit 2eac320
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 125 deletions.
18 changes: 0 additions & 18 deletions src/main/java/net/dv8tion/jda/api/JDA.java
Original file line number Diff line number Diff line change
Expand Up @@ -1862,23 +1862,11 @@ default List<RichCustomEmoji> getEmojisByName(@Nonnull String name, boolean igno
// */
//AuditableRestAction<Void> installAuxiliaryCable(int port);

/**
* The {@link net.dv8tion.jda.api.AccountType} of the currently logged in account.
* <br>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.
* <br>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}
* <br>The {@link ApplicationInfo ApplicationInfo} of the bot's application.
*/
Expand Down Expand Up @@ -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.
* <br>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
Expand All @@ -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.
* <br>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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/dv8tion/jda/api/JDABuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,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.
*
* <p><b>For {@link net.dv8tion.jda.api.AccountType#BOT}</b><br>
* <p>To get a bot token:<br>
* <ol>
* <li>Go to your <a href="https://discord.com/developers/applications/me">Discord Applications</a></li>
* <li>Create or select an already existing application</li>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/dv8tion/jda/api/entities/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -4057,7 +4057,6 @@ default AuditableRestAction<Void> modifyMemberRoles(@Nonnull Member member, @Non
* <ul>
* <li>If the specified Member is {@code null} or not from the same Guild</li>
* <li>If the specified Member already is the Guild owner</li>
* <li>If the specified Member is a bot account ({@link net.dv8tion.jda.api.AccountType#BOT AccountType.BOT})</li>
* </ul>
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +93,6 @@ public class MessageEmbed implements SerializableData

/**
* The maximum amount of total visible characters an embed can have
* <br>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)
Expand All @@ -103,13 +103,16 @@ public class MessageEmbed implements SerializableData

/**
* The maximum amount of total visible characters an embed can have
* <br>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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ default GuildMessageChannelUnion getParentMessageChannel()
* <br>The request was attempted after the parent channel was deleted.</li>
* </ul>
*
* @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
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -753,8 +751,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
Expand All @@ -771,7 +767,6 @@ default MessageCreateAction sendFiles(@Nonnull FileUpload... files)
@CheckReturnValue
default RestAction<Message> retrieveMessageById(@Nonnull String messageId)
{
AccountTypeException.check(getJDA().getAccountType(), AccountType.BOT);
Checks.isSnowflake(messageId, "Message ID");

JDAImpl jda = (JDAImpl) getJDA();
Expand Down Expand Up @@ -809,8 +804,6 @@ default RestAction<Message> 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
* <ul>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>This will automatically use the {@link net.dv8tion.jda.api.audit.ThreadLocalReason ThreadLocalReason} if no
* reason was specified via {@link #reason(String)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +73,6 @@ public RestRateLimiter.GlobalRateLimit getRateLimitHandle()
@Override
public ShardedGateway getShardedGateway(@Nonnull JDA api)
{
AccountTypeException.check(api.getAccountType(), AccountType.BOT);
return new RestActionImpl<ShardedGateway>(api, Route.Misc.GATEWAY_BOT.compile())
{
@Override
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/dv8tion/jda/internal/JDAImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -946,13 +944,6 @@ public IEventManager getEventManager()
return eventManager.getSubject();
}

@Nonnull
@Override
public AccountType getAccountType()
{
return authConfig.getAccountType();
}

@Override
public void setEventManager(IEventManager eventManager)
{
Expand Down Expand Up @@ -1126,7 +1117,6 @@ public RestAction<Webhook> retrieveWebhookById(@Nonnull String webhookId)
@Override
public RestAction<ApplicationInfo> retrieveApplicationInfo()
{
AccountTypeException.check(getAccountType(), AccountType.BOT);
Route.CompiledRoute route = Route.Applications.GET_BOT_APPLICATION.compile();
return new RestActionImpl<>(this, route, (response, request) ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DataObject> convertPresencesReplace(long responseTotal, DataArray array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,12 +31,6 @@ public AuthorizationConfig(@Nonnull String token)
setToken(token);
}

@Nonnull
public AccountType getAccountType()
{
return AccountType.BOT;
}

@Nonnull
public String getToken()
{
Expand Down

0 comments on commit 2eac320

Please sign in to comment.