diff --git a/build.gradle.kts b/build.gradle.kts index bea37ac2ca..3042fbfec0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,7 +40,7 @@ plugins { val javaVersion = JavaVersion.current() -val versionObj = Version(major = "5", minor = "1", revision = "2", classifier = null) +val versionObj = Version(major = "5", minor = "2", revision = "1", classifier = null) val isGithubAction = System.getProperty("GITHUB_ACTION") != null || System.getenv("GITHUB_ACTION") != null val isCI = System.getProperty("BUILD_NUMBER") != null // jenkins || System.getenv("BUILD_NUMBER") != null diff --git a/src/examples/java/LocalizationExample.java b/src/examples/java/LocalizationExample.java index f701d3df9a..1213408f34 100644 --- a/src/examples/java/LocalizationExample.java +++ b/src/examples/java/LocalizationExample.java @@ -1,3 +1,19 @@ +/* + * 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. + */ + import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.interactions.DiscordLocale; diff --git a/src/main/java/net/dv8tion/jda/api/JDA.java b/src/main/java/net/dv8tion/jda/api/JDA.java index 655e229d2f..5157b9beb2 100644 --- a/src/main/java/net/dv8tion/jda/api/JDA.java +++ b/src/main/java/net/dv8tion/jda/api/JDA.java @@ -23,6 +23,8 @@ import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.entities.emoji.ApplicationEmoji; +import net.dv8tion.jda.api.entities.emoji.CustomEmoji; import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; import net.dv8tion.jda.api.entities.sticker.*; import net.dv8tion.jda.api.events.GenericEvent; @@ -1750,6 +1752,64 @@ default List getEmojisByName(@Nonnull String name, boolean igno return getEmojiCache().getElementsByName(name, ignoreCase); } + /** + * Creates a new {@link ApplicationEmoji} for this bot. + * + *

Note that the bot is limited to {@value ApplicationEmoji#APPLICATION_EMOJI_CAP} Application Emojis (normal and animated). + * + * @param name + * The name for the new emoji (2-{@value CustomEmoji#EMOJI_NAME_MAX_LENGTH} characters) + * @param icon + * The {@link Icon} for the new emoji + * + * @throws IllegalArgumentException + * If null is provided or the name is not alphanumeric or not between 2 and {@value CustomEmoji#EMOJI_NAME_MAX_LENGTH} characters long + * + * @return {@link RestAction} - Type: {@link ApplicationEmoji} + */ + @Nonnull + @CheckReturnValue + RestAction createApplicationEmoji(@Nonnull String name, @Nonnull Icon icon); + + /** + * Retrieves a list of Application Emojis together with their respective creators. + * + * @return {@link RestAction RestAction} - Type: List of {@link ApplicationEmoji} + */ + @Nonnull + @CheckReturnValue + RestAction> retrieveApplicationEmojis(); + + /** + * Retrieves an application emoji together with its respective creator. + * + * @param emojiId + * The emoji id + * + * @return {@link RestAction RestAction} - Type: {@link ApplicationEmoji} + */ + @Nonnull + @CheckReturnValue + default RestAction retrieveApplicationEmojiById(long emojiId) + { + return retrieveApplicationEmojiById(Long.toUnsignedString(emojiId)); + } + + /** + * Retrieves an application emoji together with its respective creator. + * + * @param emojiId + * The emoji id + * + * @throws IllegalArgumentException + * If the provided id is not a valid snowflake + * + * @return {@link RestAction RestAction} - Type: {@link ApplicationEmoji} + */ + @Nonnull + @CheckReturnValue + RestAction retrieveApplicationEmojiById(@Nonnull String emojiId); + /** * Attempts to retrieve a {@link Sticker} object based on the provided snowflake reference. *
This works for both {@link StandardSticker} and {@link GuildSticker}, and you can resolve them using the provided {@link StickerUnion}. @@ -1873,7 +1933,7 @@ default AccountType getAccountType() { void setRequestTimeoutRetry(boolean retryOnTimeout); /** - * USed to determine whether or not autoReconnect is enabled for JDA. + * Used to determine whether or not autoReconnect is enabled for JDA. * * @return True if JDA will attempt to automatically reconnect when a connection-error is encountered. */ diff --git a/src/main/java/net/dv8tion/jda/api/JDABuilder.java b/src/main/java/net/dv8tion/jda/api/JDABuilder.java index 7d492c6112..a6c66f902b 100644 --- a/src/main/java/net/dv8tion/jda/api/JDABuilder.java +++ b/src/main/java/net/dv8tion/jda/api/JDABuilder.java @@ -99,7 +99,12 @@ public class JDABuilder protected GatewayEncoding encoding = GatewayEncoding.JSON; protected RestConfig restConfig = new RestConfig(); - private JDABuilder(@Nullable AccountType accountType, @Nullable String token, int intents) + protected JDABuilder(@Nullable String token, int intents) + { + this(AccountType.BOT, token, intents); + } + + protected JDABuilder(@Nullable AccountType accountType, @Nullable String token, int intents) { this.accountType = accountType; this.token = token; @@ -224,7 +229,7 @@ public static JDABuilder createDefault(@Nullable String token, @Nonnull Collecti return create(token, intents).applyDefault(); } - private JDABuilder applyDefault() + protected JDABuilder applyDefault() { return this.setMemberCachePolicy(MemberCachePolicy.DEFAULT) .setChunkingFilter(ChunkingFilter.NONE) @@ -344,7 +349,7 @@ public static JDABuilder createLight(@Nullable String token, @Nonnull Collection return create(token, intents).applyLight(); } - private JDABuilder applyLight() + protected JDABuilder applyLight() { return this.setMemberCachePolicy(MemberCachePolicy.NONE) .setChunkingFilter(ChunkingFilter.NONE) @@ -506,7 +511,7 @@ public static JDABuilder create(@Nonnull AccountType type, @Nullable String toke return new JDABuilder(type, token, GatewayIntent.getRaw(intents)).applyIntents(); } - private JDABuilder applyIntents() + protected JDABuilder applyIntents() { EnumSet disabledCache = EnumSet.allOf(CacheFlag.class); for (CacheFlag flag : CacheFlag.values()) @@ -1596,7 +1601,7 @@ public JDABuilder setDisabledIntents(@Nullable Collection intents { this.intents = GatewayIntent.ALL_INTENTS; if (intents != null) - this.intents &= ~GatewayIntent.getRaw(intents); + this.intents = 1 | (GatewayIntent.ALL_INTENTS & ~GatewayIntent.getRaw(intents)); return this; } @@ -1688,7 +1693,7 @@ public JDABuilder setEnabledIntents(@Nonnull GatewayIntent intent, @Nonnull Gate Checks.notNull(intent, "Intents"); Checks.noneNull(intents, "Intents"); EnumSet set = EnumSet.of(intent, intents); - return setDisabledIntents(EnumSet.complementOf(set)); + return setEnabledIntents(set); } /** @@ -1715,11 +1720,9 @@ public JDABuilder setEnabledIntents(@Nonnull GatewayIntent intent, @Nonnull Gate public JDABuilder setEnabledIntents(@Nullable Collection intents) { if (intents == null || intents.isEmpty()) - setDisabledIntents(EnumSet.allOf(GatewayIntent.class)); - else if (intents instanceof EnumSet) - setDisabledIntents(EnumSet.complementOf((EnumSet) intents)); + this.intents = 1; else - setDisabledIntents(EnumSet.complementOf(EnumSet.copyOf(intents))); + this.intents = 1 | GatewayIntent.getRaw(intents); return this; } @@ -1901,7 +1904,7 @@ private JDABuilder setFlag(ConfigFlag flag, boolean enable) return this; } - private void checkIntents() + protected void checkIntents() { boolean membersIntent = (intents & GatewayIntent.GUILD_MEMBERS.getRawValue()) != 0; if (!membersIntent && memberCachePolicy == MemberCachePolicy.ALL) diff --git a/src/main/java/net/dv8tion/jda/api/Permission.java b/src/main/java/net/dv8tion/jda/api/Permission.java index 2e9471c459..c1c0d739fe 100644 --- a/src/main/java/net/dv8tion/jda/api/Permission.java +++ b/src/main/java/net/dv8tion/jda/api/Permission.java @@ -15,15 +15,11 @@ */ package net.dv8tion.jda.api; -import net.dv8tion.jda.annotations.ForRemoval; -import net.dv8tion.jda.annotations.ReplaceWith; import net.dv8tion.jda.internal.utils.Checks; import javax.annotation.Nonnull; -import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; -import java.util.stream.Collectors; /** * Represents the bit offsets used by Discord for Permissions. @@ -85,10 +81,6 @@ public enum Permission VOICE_DEAF_OTHERS( 23, true, true, "Deafen Members"), VOICE_MOVE_OTHERS( 24, true, true, "Move Members"), VOICE_USE_VAD( 25, true, true, "Use Voice Activity"), - @Deprecated - @ForRemoval(deadline="5.1.0") - @ReplaceWith("USE_EMBEDDED_ACTIVITIES") - VOICE_START_ACTIVITIES( 39, true, true, "Use Activities"), VOICE_USE_SOUNDBOARD( 42, true, true, "Use Soundboard"), VOICE_USE_EXTERNAL_SOUNDS(45, true, true, "Use External Sounds"), VOICE_SET_STATUS( 48, true, true, "Set Voice Channel Status"), @@ -108,63 +100,6 @@ public enum Permission // This is an optimization suggested by Effective Java 3rd Edition - Item 54 public static final Permission[] EMPTY_PERMISSIONS = new Permission[0]; - /** - * Represents a raw set of all permissions - * - * @deprecated To be removed in 5.1.0 - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public static final long ALL_PERMISSIONS = Permission.getRaw(Permission.values()); - - /** - * All permissions that apply to a channel - * - * @deprecated To be removed in 5.1.0 (use {@link Permission#isChannel()} instead) - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public static final long ALL_CHANNEL_PERMISSIONS = Permission.getRaw(Arrays.stream(values()) - .filter(Permission::isChannel).collect(Collectors.toSet())); - - /** - * All Guild specific permissions which are only available to roles - * - * @deprecated To be removed in 5.1.0 (use {@link Permission#isGuild()} instead) - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public static final long ALL_GUILD_PERMISSIONS = Permission.getRaw(Arrays.stream(values()) - .filter(Permission::isGuild).collect(Collectors.toSet())); - - /** - * All text channel specific permissions which are only available in text channel permission overrides - * - * @deprecated To be removed in 5.1.0 - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public static final long ALL_TEXT_PERMISSIONS - = Permission.getRaw(MESSAGE_ADD_REACTION, MESSAGE_SEND, MESSAGE_TTS, MESSAGE_MANAGE, - MESSAGE_EMBED_LINKS, MESSAGE_ATTACH_FILES, MESSAGE_EXT_EMOJI, MESSAGE_EXT_STICKER, - MESSAGE_HISTORY, MESSAGE_MENTION_EVERYONE, - USE_APPLICATION_COMMANDS, USE_EXTERNAL_APPLICATIONS, USE_EMBEDDED_ACTIVITIES, - MANAGE_THREADS, CREATE_PUBLIC_THREADS, CREATE_PRIVATE_THREADS, - MESSAGE_SEND_IN_THREADS, MESSAGE_ATTACH_VOICE_MESSAGE, MESSAGE_SEND_POLLS); - - /** - * All voice channel specific permissions which are only available in voice channel permission overrides - * - * @deprecated To be removed in 5.1.0 - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public static final long ALL_VOICE_PERMISSIONS - = Permission.getRaw(VOICE_STREAM, VOICE_CONNECT, VOICE_SPEAK, VOICE_MUTE_OTHERS, - VOICE_DEAF_OTHERS, VOICE_MOVE_OTHERS, VOICE_USE_VAD, - PRIORITY_SPEAKER, REQUEST_TO_SPEAK, USE_EMBEDDED_ACTIVITIES, - VOICE_USE_SOUNDBOARD, VOICE_USE_EXTERNAL_SOUNDS, VOICE_SET_STATUS); - private final int offset; private final long raw; private final boolean isGuild, isChannel; @@ -235,34 +170,6 @@ public boolean isChannel() return isChannel; } - /** - * Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel TextChannels} - * - * @return True, if and only if this permission can only be applied to text channels - * - * @deprecated To be removed in 5.1.0 - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public boolean isText() - { - return (raw & ALL_TEXT_PERMISSIONS) == raw; - } - - /** - * Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel VoiceChannels} - * - * @return True, if and only if this permission can only be applied to voice channels - * - * @deprecated To be removed in 5.1.0 - */ - @Deprecated - @ForRemoval(deadline = "5.1.0") - public boolean isVoice() - { - return (raw & ALL_VOICE_PERMISSIONS) == raw; - } - /** * Gets the first {@link net.dv8tion.jda.api.Permission Permission} relating to the provided offset. *
If there is no {@link net.dv8tion.jda.api.Permission Permssions} that matches the provided diff --git a/src/main/java/net/dv8tion/jda/api/entities/SkuSnowflake.java b/src/main/java/net/dv8tion/jda/api/entities/SkuSnowflake.java new file mode 100644 index 0000000000..6cbb6191f5 --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/entities/SkuSnowflake.java @@ -0,0 +1,61 @@ +/* + * 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.entities; + +import net.dv8tion.jda.api.utils.MiscUtil; +import net.dv8tion.jda.internal.entities.SkuSnowflakeImpl; + +import javax.annotation.Nonnull; + +/** + * Represents an abstract SKU reference by only the SKU ID. + * + *

This is used for methods which only need a SKU ID to function, you cannot use this for getting any properties. + */ +public interface SkuSnowflake extends ISnowflake +{ + /** + * Creates a SKU instance which only wraps an ID. + * + * @param id + * The SKU id + * + * @return A SKU snowflake instance + */ + @Nonnull + static SkuSnowflake fromId(long id) + { + return new SkuSnowflakeImpl(id); + } + + /** + * Creates a SKU instance which only wraps an ID. + * + * @param id + * The SKU id + * + * @throws IllegalArgumentException + * If the provided ID is not a valid snowflake + * + * @return A SKU snowflake instance + */ + @Nonnull + static SkuSnowflake fromId(@Nonnull String id) + { + return fromId(MiscUtil.parseSnowflake(id)); + } +} diff --git a/src/main/java/net/dv8tion/jda/api/entities/emoji/ApplicationEmoji.java b/src/main/java/net/dv8tion/jda/api/entities/emoji/ApplicationEmoji.java new file mode 100644 index 0000000000..a97743f621 --- /dev/null +++ b/src/main/java/net/dv8tion/jda/api/entities/emoji/ApplicationEmoji.java @@ -0,0 +1,84 @@ +/* + * 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.entities.emoji; + +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.entities.Icon; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.managers.ApplicationEmojiManager; +import net.dv8tion.jda.api.requests.RestAction; + +import javax.annotation.CheckReturnValue; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents a Custom Emoji hosted on the Bot Account. + * + *

This does not represent unicode emojis like they are used in the official client! + * The format {@code :smiley:} is a client-side alias which is replaced by the unicode emoji, not a custom emoji. + * + * @see JDA#createApplicationEmoji(String, Icon) + * @see JDA#retrieveApplicationEmojiById(long) + * @see JDA#retrieveApplicationEmojis() + */ +public interface ApplicationEmoji extends CustomEmoji +{ + int APPLICATION_EMOJI_CAP = 2000; + + /** + * The {@link net.dv8tion.jda.api.JDA JDA} instance of this emoji + * + * @return The JDA instance of this emoji + */ + @Nonnull + JDA getJDA(); + + /** + * The user who created this emoji + * + * @return The user who created this emoji + */ + @Nullable + User getOwner(); + + /** + * Deletes this emoji. + * + *

Possible ErrorResponses include: + *

+ * + * @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} + * The RestAction to delete this emoji. + */ + @Nonnull + @CheckReturnValue + RestAction delete(); + + /** + * The {@link ApplicationEmojiManager Manager} for this emoji, used to modify + * properties of the emoji like name. + * + * @return The ApplicationEmojiManager for this emoji + */ + @Nonnull + @CheckReturnValue + ApplicationEmojiManager getManager(); +} diff --git a/src/main/java/net/dv8tion/jda/api/entities/emoji/CustomEmoji.java b/src/main/java/net/dv8tion/jda/api/entities/emoji/CustomEmoji.java index 3b4a7abc36..b3e1183d0f 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/emoji/CustomEmoji.java +++ b/src/main/java/net/dv8tion/jda/api/entities/emoji/CustomEmoji.java @@ -38,6 +38,8 @@ */ public interface CustomEmoji extends Emoji, IMentionable { + int EMOJI_NAME_MAX_LENGTH = 32; + /** Template for {@link #getImageUrl()} */ String ICON_URL = "https://cdn.discordapp.com/emojis/%s.%s"; diff --git a/src/main/java/net/dv8tion/jda/api/entities/emoji/Emoji.java b/src/main/java/net/dv8tion/jda/api/entities/emoji/Emoji.java index 542b7a87f0..8faeed59f6 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/emoji/Emoji.java +++ b/src/main/java/net/dv8tion/jda/api/entities/emoji/Emoji.java @@ -233,8 +233,9 @@ enum Type */ UNICODE, /** - * Custom Guild Emoji. + * Custom Guild Emoji or Custom Application Emoji. *
This represents emojis which were created by users and added to a guild. + *
This can also represent emojis which were created and owned by a specific application. */ CUSTOM, } diff --git a/src/main/java/net/dv8tion/jda/api/entities/emoji/EmojiUnion.java b/src/main/java/net/dv8tion/jda/api/entities/emoji/EmojiUnion.java index 18ae0f55cb..9f487c90bb 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/emoji/EmojiUnion.java +++ b/src/main/java/net/dv8tion/jda/api/entities/emoji/EmojiUnion.java @@ -22,7 +22,8 @@ * Represents possible {@link Emoji} types. * *

This delegates the emoji methods for some concrete emoji type, - * but can be converted to a concrete type using either {@link #asUnicode()} or {@link #asCustom()}. + * but can be converted to a concrete type using either {@link #asUnicode()}, + * {@link #asCustom()}, {@link #asRich()} or {@link #asApplication()}. */ public interface EmojiUnion extends Emoji { @@ -47,4 +48,26 @@ public interface EmojiUnion extends Emoji */ @Nonnull CustomEmoji asCustom(); + + /** + * Returns the underlying {@link RichCustomEmoji} if applicable. + * + * @throws IllegalStateException + * If this is not a {@link RichCustomEmoji} + * + * @return The {@link RichCustomEmoji} + */ + @Nonnull + RichCustomEmoji asRich(); + + /** + * Returns the underlying {@link ApplicationEmoji} if applicable. + * + * @throws IllegalStateException + * If this is not a {@link ApplicationEmoji} + * + * @return The {@link ApplicationEmoji} + */ + @Nonnull + ApplicationEmoji asApplication(); } diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java index 5af0d65207..8d0ae477f9 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiAddedEvent.java @@ -27,7 +27,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java index 7a910f17bc..fb713c433d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/EmojiRemovedEvent.java @@ -27,7 +27,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java index efd55eeb28..5d49a6574b 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/GenericEmojiEvent.java @@ -29,7 +29,7 @@ *

Requirements
* *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/package-info.java b/src/main/java/net/dv8tion/jda/api/events/emoji/package-info.java index 4ddab90e8a..00ee5fa217 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/package-info.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/package-info.java @@ -22,7 +22,7 @@ *

Requirements
* *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java index 94e6095cbb..d9e1c08ba3 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateNameEvent.java @@ -29,7 +29,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java index 4f45dafd69..4930d1bac1 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/EmojiUpdateRolesEvent.java @@ -31,7 +31,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java index 1a50e129dc..e8e07af094 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/GenericEmojiUpdateEvent.java @@ -30,7 +30,7 @@ *

Requirements
* *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/emoji/update/package-info.java b/src/main/java/net/dv8tion/jda/api/events/emoji/update/package-info.java index afec8be948..189d3e4d77 100644 --- a/src/main/java/net/dv8tion/jda/api/events/emoji/update/package-info.java +++ b/src/main/java/net/dv8tion/jda/api/events/emoji/update/package-info.java @@ -20,7 +20,7 @@ *

Requirements
* *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#EMOJI EMOJI} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java index b0d1a97b55..5e3b7acde5 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/scheduledevent/update/GenericScheduledEventUpdateEvent.java @@ -1,3 +1,19 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package net.dv8tion.jda.api.events.guild.scheduledevent.update; import net.dv8tion.jda.api.JDA; diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/update/GuildUpdateSafetyAlertsChannelEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/update/GuildUpdateSafetyAlertsChannelEvent.java index aaf92ae8e7..8ff105726b 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/update/GuildUpdateSafetyAlertsChannelEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/update/GuildUpdateSafetyAlertsChannelEvent.java @@ -1,3 +1,19 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package net.dv8tion.jda.api.events.guild.update; import net.dv8tion.jda.api.JDA; diff --git a/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java b/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java index b3bb9dc6d9..7a0c4ef531 100644 --- a/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java @@ -125,6 +125,7 @@ public ModalCallbackAction replyModal(@Nonnull Modal modal) @Nonnull @Override + @Deprecated @CheckReturnValue public PremiumRequiredCallbackAction replyWithPremiumRequired() { diff --git a/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java b/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java index 7e766e76ef..a470852bea 100644 --- a/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java @@ -132,6 +132,7 @@ public ModalCallbackAction replyModal(@Nonnull Modal modal) @Nonnull @Override + @Deprecated @CheckReturnValue public PremiumRequiredCallbackAction replyWithPremiumRequired() { diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java index 67b74471e2..4d2c9b68b3 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GenericGuildStickerEvent.java @@ -29,7 +29,7 @@ *

Requirements * *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java index 515f8d60dc..0678d3a499 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerAddedEvent.java @@ -28,7 +28,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java index df6d362409..c07b2260cf 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/GuildStickerRemovedEvent.java @@ -28,7 +28,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/package-info.java b/src/main/java/net/dv8tion/jda/api/events/sticker/package-info.java index dbb24f662f..385403477e 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/package-info.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/package-info.java @@ -21,7 +21,7 @@ *

Requirements * *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java index d995e71546..0f638f0160 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GenericGuildStickerUpdateEvent.java @@ -31,7 +31,7 @@ *

Requirements
* *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java index a347a7c6ad..71703c70c3 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateAvailableEvent.java @@ -28,7 +28,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java index 70c29a215f..541ba85eb6 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateDescriptionEvent.java @@ -30,7 +30,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java index 22c6cf89cf..91d9b69ead 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateNameEvent.java @@ -30,7 +30,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java index 3f37aa8534..6acd8ee86d 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/GuildStickerUpdateTagsEvent.java @@ -31,7 +31,7 @@ *

Requirements
* *

This event requires the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! * diff --git a/src/main/java/net/dv8tion/jda/api/events/sticker/update/package-info.java b/src/main/java/net/dv8tion/jda/api/events/sticker/update/package-info.java index d51fac1c55..1cf54e1464 100644 --- a/src/main/java/net/dv8tion/jda/api/events/sticker/update/package-info.java +++ b/src/main/java/net/dv8tion/jda/api/events/sticker/update/package-info.java @@ -20,7 +20,7 @@ *

Requirements * *

These events require the {@link net.dv8tion.jda.api.utils.cache.CacheFlag#STICKER STICKER} CacheFlag to be enabled, which requires - * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EMOJIS_AND_STICKERS GUILD_EMOJIS_AND_STICKERS} intent. + * the {@link net.dv8tion.jda.api.requests.GatewayIntent#GUILD_EXPRESSIONS GUILD_EXPRESSIONS} intent. * *
{@link net.dv8tion.jda.api.JDABuilder#createLight(String) createLight(String)} disables that CacheFlag by default! */ diff --git a/src/main/java/net/dv8tion/jda/api/interactions/Interaction.java b/src/main/java/net/dv8tion/jda/api/interactions/Interaction.java index 32fbb0d545..9f2e154d5e 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/Interaction.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/Interaction.java @@ -48,8 +48,6 @@ *
Which supports choice suggestions for auto-complete interactions via {@link IAutoCompleteCallback#replyChoices(Command.Choice...)} *

  • {@link IModalCallback} *
    Which supports replying using a {@link Modal} via {@link IModalCallback#replyModal(Modal)}
  • - *
  • {@link IPremiumRequiredReplyCallback} - *
    Which will reply stating that an {@link Entitlement Entitlement} is required
  • * * *

    Once the interaction is acknowledged, you can not reply with these methods again. If the interaction is a {@link IDeferrableCallback deferrable}, diff --git a/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java b/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java index a25b923c94..03339af158 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java @@ -16,8 +16,10 @@ package net.dv8tion.jda.api.interactions.callbacks; -import net.dv8tion.jda.api.requests.restaction.interactions.PremiumRequiredCallbackAction; import net.dv8tion.jda.api.entities.Entitlement; +import net.dv8tion.jda.api.entities.SkuSnowflake; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.requests.restaction.interactions.PremiumRequiredCallbackAction; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; @@ -28,10 +30,19 @@ *

    Replying with {@link #replyWithPremiumRequired()} will automatically acknowledge this interaction. * *

    Note:This interaction requires monetization to be enabled. + * + * @deprecated Replaced with {@link Button#premium(SkuSnowflake)}, + * see the Discord change logs for more details. */ +@Deprecated public interface IPremiumRequiredReplyCallback extends IDeferrableCallback { + /** + * @deprecated Replaced with {@link Button#premium(SkuSnowflake)}, + * see the Discord change logs for more details. + */ @Nonnull + @Deprecated @CheckReturnValue PremiumRequiredCallbackAction replyWithPremiumRequired(); } diff --git a/src/main/java/net/dv8tion/jda/api/interactions/components/LayoutComponent.java b/src/main/java/net/dv8tion/jda/api/interactions/components/LayoutComponent.java index 167c4868d6..15070e0271 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/components/LayoutComponent.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/components/LayoutComponent.java @@ -20,6 +20,7 @@ import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; import net.dv8tion.jda.api.utils.data.SerializableData; import net.dv8tion.jda.internal.utils.Checks; +import net.dv8tion.jda.internal.utils.ComponentsUtil; import net.dv8tion.jda.internal.utils.Helpers; import org.jetbrains.annotations.Unmodifiable; @@ -207,7 +208,8 @@ default boolean isValid() *
    This will locate and replace the existing component with the specified ID. If you provide null it will be removed instead. * * @param id - * The custom id of this component, can also be a URL for a {@link Button} with {@link ButtonStyle#LINK} + * The custom id of this component, can also be a URL for a {@link Button} with {@link ButtonStyle#LINK}, + * or an SKU id for {@link ButtonStyle#PREMIUM} * @param newComponent * The new component or null to remove it * @@ -227,7 +229,7 @@ default ItemComponent updateComponent(@Nonnull String id, @Nullable ItemComponen if (!(component instanceof ActionComponent)) continue; ActionComponent action = (ActionComponent) component; - if (id.equals(action.getId()) || (action instanceof Button && id.equals(((Button) action).getUrl()))) + if (ComponentsUtil.isSameIdentifier(action, id)) { if (newComponent == null) it.remove(); diff --git a/src/main/java/net/dv8tion/jda/api/interactions/components/buttons/Button.java b/src/main/java/net/dv8tion/jda/api/interactions/components/buttons/Button.java index a13b6807e2..dcf7628394 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/components/buttons/Button.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/components/buttons/Button.java @@ -16,6 +16,7 @@ package net.dv8tion.jda.api.interactions.components.buttons; +import net.dv8tion.jda.api.entities.SkuSnowflake; import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.entities.emoji.EmojiUnion; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; @@ -91,7 +92,8 @@ public interface Button extends ActionComponent int URL_MAX_LENGTH = 512; /** - * The visible text on the button. + * The visible text on the button, + * or an empty string if this is a {@link ButtonStyle#PREMIUM PREMIUM}-style button. * * @return The button label */ @@ -114,6 +116,14 @@ public interface Button extends ActionComponent @Nullable String getUrl(); + /** + * The target SKU for this button, if it is a {@link ButtonStyle#PREMIUM PREMIUM}-style Button. + * + * @return The target SKU or {@code null} + */ + @Nullable + SkuSnowflake getSku(); + /** * The emoji attached to this button. *
    This can be either {@link Emoji.Type#UNICODE unicode} or {@link Emoji.Type#CUSTOM custom}. @@ -143,7 +153,7 @@ default Button asEnabled() @CheckReturnValue default Button withDisabled(boolean disabled) { - return new ButtonImpl(getId(), getLabel(), getStyle(), getUrl(), disabled, getEmoji()); + return new ButtonImpl(getId(), getLabel(), getStyle(), getUrl(), getSku(), disabled, getEmoji()).checkValid(); } /** @@ -152,13 +162,16 @@ default Button withDisabled(boolean disabled) * @param emoji * The emoji to use * + * @throws IllegalArgumentException + * If this is a {@link ButtonStyle#PREMIUM PREMIUM}-styled button + * * @return New button with emoji */ @Nonnull @CheckReturnValue default Button withEmoji(@Nullable Emoji emoji) { - return new ButtonImpl(getId(), getLabel(), getStyle(), getUrl(), isDisabled(), emoji); + return new ButtonImpl(getId(), getLabel(), getStyle(), getUrl(), getSku(), isDisabled(), emoji).checkValid(); } /** @@ -169,6 +182,7 @@ default Button withEmoji(@Nullable Emoji emoji) * * @throws IllegalArgumentException *