Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Permissions for JDA5 #1797

Merged
merged 10 commits into from
Sep 19, 2021
8 changes: 4 additions & 4 deletions src/main/java/net/dv8tion/jda/api/JDA.java
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ default List<StoreChannel> getStoreChannelsByName(@Nonnull String name, boolean
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is possible that you will see fewer channels than this returns. This is because the discord
* client hides any {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
* {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} permission in.
*
* <p>This copies the backing store into a list. This means every call
* creates a new list with O(n) complexity. It is recommended to store this into
Expand All @@ -1699,7 +1699,7 @@ default List<TextChannel> getTextChannels()
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is you will not see the channel that this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
* {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} permission in.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
Expand All @@ -1723,7 +1723,7 @@ default TextChannel getTextChannelById(@Nonnull String id)
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is you will not see the channel that this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
* {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} permission in.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
Expand All @@ -1744,7 +1744,7 @@ default TextChannel getTextChannelById(long id)
* not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord
* client, it is possible that you will see fewer channels than this returns. This is because the discord client
* hides any {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} that you don't have the
* {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} permission in.
* {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} permission in.
*
* @param name
* The name of the requested {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}.
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/net/dv8tion/jda/api/Permission.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ public enum Permission
MESSAGE_ADD_REACTION( 6, true, true, "Add Reactions"),
VIEW_AUDIT_LOGS( 7, true, false, "View Audit Logs"),
PRIORITY_SPEAKER( 8, true, true, "Priority Speaker"),
VIEW_GUILD_INSIGHTS(19, true, false, "View Server Insights"),
VIEW_GUILD_INSIGHTS( 19, true, false, "View Server Insights"),

// Applicable to all channel types
VIEW_CHANNEL( 10, true, true, "Read Text Channels & See Voice Channels"),

// Text Permissions
MESSAGE_READ( 10, true, true, "Read Messages"),
MESSAGE_WRITE( 11, true, true, "Send Messages"),
MESSAGE_TTS( 12, true, true, "Send TTS Messages"),
MESSAGE_MANAGE( 13, true, true, "Manage Messages"),
Expand All @@ -52,7 +51,7 @@ public enum Permission
MESSAGE_HISTORY( 16, true, true, "Read History"),
MESSAGE_MENTION_EVERYONE(17, true, true, "Mention Everyone"),
MESSAGE_EXT_EMOJI( 18, true, true, "Use External Emojis"),
USE_SLASH_COMMANDS( 31, true, true, "Use Slash Commands"),
USE_APPLICATION_COMMANDS(31, true, true, "Use Application Commands"),

MANAGE_THREADS( 34, true, true, "Manage Threads"),
USE_PUBLIC_THREADS( 35, true, true, "Use Public Threads"),
Expand All @@ -70,10 +69,10 @@ public enum Permission
NICKNAME_CHANGE(26, true, false, "Change Nickname"),
NICKNAME_MANAGE(27, true, false, "Manage Nicknames"),

MANAGE_ROLES( 28, true, false, "Manage Roles"),
MANAGE_PERMISSIONS(28, false, true, "Manage Permissions"),
MANAGE_WEBHOOKS( 29, true, true, "Manage Webhooks"),
MANAGE_EMOTES( 30, true, false, "Manage Emojis"),
MANAGE_ROLES( 28, true, false, "Manage Roles"),
MANAGE_PERMISSIONS( 28, false, true, "Manage Permissions"),
MANAGE_WEBHOOKS( 29, true, true, "Manage Webhooks"),
MANAGE_EMOTES_AND_STICKERS(30, true, false, "Manage Emojis and Stickers"),

REQUEST_TO_SPEAK( 32, true, true, "Request to Speak"),

Expand Down Expand Up @@ -108,7 +107,7 @@ public enum Permission
public static final long ALL_TEXT_PERMISSIONS
= Permission.getRaw(MESSAGE_ADD_REACTION, MESSAGE_WRITE, MESSAGE_TTS,
MESSAGE_MANAGE, MESSAGE_EMBED_LINKS, MESSAGE_ATTACH_FILES,
MESSAGE_HISTORY, MESSAGE_MENTION_EVERYONE, USE_SLASH_COMMANDS,
MESSAGE_HISTORY, MESSAGE_MENTION_EVERYONE, USE_APPLICATION_COMMANDS,
MANAGE_THREADS, USE_PUBLIC_THREADS, USE_PRIVATE_THREADS);

/**
Expand Down Expand Up @@ -280,7 +279,7 @@ public static long getRaw(@Nonnull Permission... permissions)
/**
* This is effectively the opposite of {@link #getPermissions(long)}, this takes a Collection of {@link net.dv8tion.jda.api.Permission Permissions}
* and returns the raw offset {@code long} representation of the permissions.
* <br>Example: {@code getRaw(EnumSet.of(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))}
* <br>Example: {@code getRaw(EnumSet.of(Permission.VIEW_CHANNEL, Permission.MESSAGE_WRITE))}
*
* @param permissions
* The Collection of permissions of which to form into the raw long representation.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dv8tion/jda/api/entities/Emote.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ default boolean hasRoles()
* @throws java.lang.UnsupportedOperationException
* If this emote is managed by discord ({@link #isManaged()})
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* if the Permission {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES MANAGE_EMOTES} is not given
* if the Permission {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS MANAGE_EMOTES_AND_STICKERS} is not given
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction}
* The RestAction to delete this Emote.
Expand All @@ -189,7 +189,7 @@ default boolean hasRoles()
* @throws IllegalStateException
* if this emote is created from a message or the bot does not have access to the emote
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES Permission.MANAGE_EMOTES}
* If the currently logged in account does not have {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}
*
* @return The EmoteManager for this Emote
*/
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/dv8tion/jda/api/entities/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ default List<Emote> getEmotesByName(@Nonnull String name, boolean ignoreCase)
* Retrieves an immutable list of emotes together with their respective creators.
*
* <p>Note that {@link ListedEmote#getUser()} is only available if the currently
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES Permission.MANAGE_EMOTES}.
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}.
*
* @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: List of {@link net.dv8tion.jda.api.entities.ListedEmote ListedEmote}
*
Expand All @@ -2350,7 +2350,7 @@ default List<Emote> getEmotesByName(@Nonnull String name, boolean ignoreCase)
* <br><b>This does not include unicode emoji.</b>
*
* <p>Note that {@link ListedEmote#getUser()} is only available if the currently
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES Permission.MANAGE_EMOTES}.
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
Expand All @@ -2377,7 +2377,7 @@ default List<Emote> getEmotesByName(@Nonnull String name, boolean ignoreCase)
* Retrieves a listed emote together with its respective creator.
*
* <p>Note that {@link ListedEmote#getUser()} is only available if the currently
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES Permission.MANAGE_EMOTES}.
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
Expand All @@ -2404,7 +2404,7 @@ default RestAction<ListedEmote> retrieveEmoteById(long id)
* Retrieves a listed emote together with its respective creator.
*
* <p>Note that {@link ListedEmote#getUser()} is only available if the currently
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES Permission.MANAGE_EMOTES}.
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
Expand Down Expand Up @@ -2434,7 +2434,7 @@ default RestAction<ListedEmote> retrieveEmote(@Nonnull Emote emote)
if (emote instanceof ListedEmote)
{
ListedEmote listedEmote = (ListedEmote) emote;
if (listedEmote.hasUser() || !getSelfMember().hasPermission(Permission.MANAGE_EMOTES))
if (listedEmote.hasUser() || !getSelfMember().hasPermission(Permission.MANAGE_EMOTES_AND_STICKERS))
return listedEmote;
}
return null;
Expand Down Expand Up @@ -2599,7 +2599,7 @@ default RestAction<Ban> retrieveBan(@Nonnull User bannedUser)
* that is not directed at a specific {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
*
* <p>Note: This channel is the first channel in the guild (ordered by position) that the {@link #getPublicRole()}
* has the {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} in.
* has the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} in.
*
* @return The {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} representing the default channel for this guild
*/
Expand Down Expand Up @@ -5381,7 +5381,7 @@ default RoleAction createCopyOfRole(@Nonnull Role role)
/**
* Creates a new {@link net.dv8tion.jda.api.entities.Emote Emote} in this Guild.
* <br>If one or more Roles are specified the new Emote will only be available to Members with any of the specified Roles (see {@link Member#canInteract(Emote)})
* <br>For this to be successful, the logged in account has to have the {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES MANAGE_EMOTES} Permission.
* <br>For this to be successful, the logged in account has to have the {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS MANAGE_EMOTES_AND_STICKERS} Permission.
*
* <p><b><u>Unicode emojis are not included as {@link net.dv8tion.jda.api.entities.Emote Emote}!</u></b>
*
Expand All @@ -5406,7 +5406,7 @@ default RoleAction createCopyOfRole(@Nonnull Role role)
* <br>If no roles are provided the Emote will be available to all Members of this Guild
*
* @throws net.dv8tion.jda.api.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES MANAGE_EMOTES} Permission
* If the logged in account does not have the {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS MANAGE_EMOTES_AND_STICKERS} Permission
*
* @return {@link net.dv8tion.jda.api.requests.restaction.AuditableRestAction AuditableRestAction} - Type: {@link net.dv8tion.jda.api.entities.Emote Emote}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface GuildMessageChannel extends GuildChannel, MessageChannel
/**
* Whether we can send messages in this channel.
* <br>This is an overload of {@link #canTalk(Member)} with the SelfMember.
* <br>Checks for both {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} and
* <br>Checks for both {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} and
* {@link net.dv8tion.jda.api.Permission#MESSAGE_WRITE Permission.MESSAGE_WRITE}.
*
* @return True, if we are able to read and send messages in this channel
Expand All @@ -26,7 +26,7 @@ public interface GuildMessageChannel extends GuildChannel, MessageChannel
/**
* Whether the specified {@link net.dv8tion.jda.api.entities.Member}
* can send messages in this channel.
* <br>Checks for both {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} and
* <br>Checks for both {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} and
* {@link net.dv8tion.jda.api.Permission#MESSAGE_WRITE Permission.MESSAGE_WRITE}.
*
* @param member
Expand Down Expand Up @@ -54,7 +54,7 @@ public interface GuildMessageChannel extends GuildChannel, MessageChannel
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
Expand Down Expand Up @@ -117,7 +117,7 @@ public interface GuildMessageChannel extends GuildChannel, MessageChannel
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
Expand Down Expand Up @@ -177,7 +177,7 @@ default RestAction<Void> removeReactionById(long messageId, @Nonnull String unic
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
Expand Down Expand Up @@ -238,7 +238,7 @@ default RestAction<Void> removeReactionById(@Nonnull String messageId, @Nonnull
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The request was attempted after the account lost access to the
* {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ}
* typically due to being kicked or removed, or after {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL}
* was revoked in the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* <br>Also can happen if the account lost the {@link net.dv8tion.jda.api.Permission#MESSAGE_HISTORY Permission.MESSAGE_HISTORY}</li>
*
Expand Down Expand Up @@ -391,7 +391,7 @@ default RestAction<Void> removeReactionById(long messageId, @Nonnull Emote emote
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked, or the
* due to {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed.</li>
*
Expand Down Expand Up @@ -426,7 +426,7 @@ default RestAction<Void> removeReactionById(long messageId, @Nonnull Emote emote
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>The clear-reactions request was attempted after the account lost access to the {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}
* due to {@link net.dv8tion.jda.api.Permission#MESSAGE_READ Permission.MESSAGE_READ} being revoked, or the
* due to {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} being revoked, or the
* account lost access to the {@link net.dv8tion.jda.api.entities.Guild Guild}
* typically due to being kicked or removed.</li>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface IMemberContainer extends GuildChannel
/**
* A List of all {@link net.dv8tion.jda.api.entities.Member Members} that are in this GuildChannel
* <br>For {@link net.dv8tion.jda.api.entities.TextChannel TextChannels},
* this returns all Members with the {@link net.dv8tion.jda.api.Permission#MESSAGE_READ} Permission.
* this returns all Members with the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} Permission.
* <br>For {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels},
* this returns all Members that joined that VoiceChannel.
* <br>For {@link net.dv8tion.jda.api.entities.Category Categories},
Expand Down
Loading