From cb7fa41b6c3c88075af114f3be2f010a7e362c2b Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:14:55 +0100 Subject: [PATCH 1/7] Remove deprecated declarations --- .../commands/text/HelpBuilderConsumer.java | 31 +-- .../api/commands/text/TextCommand.java | 54 ----- .../api/localization/DefaultMessages.java | 218 ------------------ .../application/ApplicationCommand.kt | 43 ---- .../api/core/config/BApplicationConfig.kt | 15 -- .../botcommands/api/core/config/BConfig.kt | 20 -- .../messages/BotCommandsMessagesFactory.kt | 8 +- .../core/service/DefaultServiceContainer.kt | 4 - .../api/core/waiter/EventWaiter.kt | 3 - .../localization/DefaultMessagesFactory.kt | 41 ---- .../api/localization/LocalizableAction.kt | 41 ---- .../context/AppLocalizationContext.kt | 7 - .../context/LocalizationContext.kt | 146 ------------ .../interaction/GuildLocaleProvider.kt | 17 +- .../interaction/LocalizableEditCallback.kt | 53 ----- .../interaction/LocalizableInteractionHook.kt | 101 -------- .../interaction/LocalizableReplyCallback.kt | 53 ----- .../interaction/UserLocaleProvider.kt | 17 +- .../text/LocalizableTextCommand.kt | 105 --------- .../text/TextCommandLocaleProvider.kt | 18 +- .../api/pagination/UsedComponentSet.kt | 13 -- ...tCommandsMessagesDefaultMessagesAdapter.kt | 103 --------- ...ommandsMessagesFactoryAutoConfiguration.kt | 30 --- ...gesFactoryDefaultMessagesFactoryAdapter.kt | 27 --- .../core/service/BCServiceContainerImpl.kt | 5 +- .../internal/core/waiter/EventWaiterImpl.kt | 3 +- .../localization/LocalizationContextImpl.kt | 9 - ...DefaultMessagesFactoryAutoConfiguration.kt | 25 -- .../FallbackDefaultMessagesFactory.kt | 32 --- .../LocalizableInteractionFactory.kt | 8 +- .../interaction/LocalizableInteractionImpl.kt | 11 - .../DefaultGuildLocaleProvider.kt | 4 - .../DefaultUserLocaleProvider.kt | 4 - .../text/LocalizableTextCommandFactory.kt | 8 +- .../text/LocalizableTextCommandImpl.kt | 11 - .../DefaultTextCommandLocaleProvider.kt | 4 - .../messages/BotCommandsMessagesTests.kt | 44 ---- .../api/core/config/JDAConfiguration.kt | 40 +--- .../core/config/BotCommandsConfigurations.kt | 5 - 39 files changed, 23 insertions(+), 1358 deletions(-) delete mode 100644 BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/TextCommand.java delete mode 100644 BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/DefaultMessages.java delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/commands/application/ApplicationCommand.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/service/DefaultServiceContainer.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/DefaultMessagesFactory.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesDefaultMessagesAdapter.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/DefaultMessagesFactoryAutoConfiguration.kt delete mode 100644 BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/FallbackDefaultMessagesFactory.kt diff --git a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/HelpBuilderConsumer.java b/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/HelpBuilderConsumer.java index d662585a9..de09f8a3d 100644 --- a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/HelpBuilderConsumer.java +++ b/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/HelpBuilderConsumer.java @@ -4,9 +4,6 @@ import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService; import net.dv8tion.jda.api.EmbedBuilder; import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - -import java.util.Objects; /** * A consumer that's called when a help embed is about to be sent. @@ -22,34 +19,12 @@ @NullMarked @InterfacedService(acceptMultiple = false) public interface HelpBuilderConsumer { - /** - * The function called when building a help embed - * - * @param builder The {@link EmbedBuilder} to fill / override - * @param isGlobal {@code true} if the embed is showing all the commands, - * {@code false} if the embed is for a specific command - * @param commandInfo The text command to retrieve the help from - *
Will be null if {@code isGlobal} is {@code true} - * - * @deprecated Replaced by {@link #acceptGlobal(EmbedBuilder)} and {@link #acceptCommand(EmbedBuilder, TextCommandInfo)} - */ - @Deprecated(forRemoval = true) - default void accept(EmbedBuilder builder, boolean isGlobal, @Nullable TextCommandInfo commandInfo) { - if (isGlobal) { - acceptGlobal(builder); - } else { - acceptCommand(builder, Objects.requireNonNull(commandInfo)); - } - } - /** * Customizes the given {@link EmbedBuilder} when showing help for all commands. * * @param builder The embed to customize */ - default void acceptGlobal(EmbedBuilder builder) { - accept(builder, true, null); - } + void acceptGlobal(EmbedBuilder builder); /** * Customizes the given {@link EmbedBuilder} when showing help for a specific command. @@ -57,7 +32,5 @@ default void acceptGlobal(EmbedBuilder builder) { * @param builder The embed to customize * @param commandInfo The command to customize the embed for */ - default void acceptCommand(EmbedBuilder builder, TextCommandInfo commandInfo) { - accept(builder, false, commandInfo); - } + void acceptCommand(EmbedBuilder builder, TextCommandInfo commandInfo); } diff --git a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/TextCommand.java b/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/TextCommand.java deleted file mode 100644 index ee1312f56..000000000 --- a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/commands/text/TextCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.github.freya022.botcommands.api.commands.text; - -import io.github.freya022.botcommands.api.commands.CommandPath; -import io.github.freya022.botcommands.api.commands.text.annotations.JDATextCommandVariation; -import io.github.freya022.botcommands.api.commands.text.builder.TextCommandBuilder; -import io.github.freya022.botcommands.api.commands.text.provider.TextCommandProvider; -import io.github.freya022.botcommands.api.core.reflect.ParameterType; -import net.dv8tion.jda.api.EmbedBuilder; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - -import java.util.function.Consumer; - -/** - * Base class for annotated text commands. - * - *

You are not required to use this if you use {@link TextCommandProvider} - * - * @see JDATextCommandVariation @JDATextCommandVariation - * - * @deprecated This superclass is no longer mandatory, if you override methods from it, implement them using their respective interfaces - */ -@NullMarked -@Deprecated -public abstract class TextCommand implements TextCommandHelpConsumer, TextGeneratedValueSupplierProvider { - /** - *

Returns a detailed embed of what the command is, it is used by the internal {@code help} command

- *

The {@code help} command will automatically set the embed title to be {@code Command '[command_name]'} but can be overridden

- *

It will also set the embed's description to be the command's description, you can override with {@link EmbedBuilder#setDescription(CharSequence)}

- * - * @return The EmbedBuilder to use as a detailed description - * - * @see TextCommandBuilder#setDetailedDescription(kotlin.jvm.functions.Function1) DSL equivalent - */ - @Nullable - public Consumer getDetailedDescription() { - return null; - } - - @Override - public final void accept(EmbedBuilder builder) { - Consumer consumer = getDetailedDescription(); - if (consumer != null) { - consumer.accept(builder); - } - } - - @Override - public TextGeneratedValueSupplier getGeneratedValueSupplier(CommandPath commandPath, - String optionName, - ParameterType parameterType) { - throw new IllegalArgumentException("Option '%s' in command path '%s' is a generated option but no generated value supplier has been given".formatted(optionName, commandPath.getFullPath())); - } -} diff --git a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/DefaultMessages.java b/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/DefaultMessages.java deleted file mode 100644 index bb3bff4a4..000000000 --- a/BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/DefaultMessages.java +++ /dev/null @@ -1,218 +0,0 @@ -package io.github.freya022.botcommands.api.localization; - -import io.github.freya022.botcommands.api.localization.providers.LocalizationMapProvider; -import io.github.freya022.botcommands.api.localization.readers.LocalizationMapReader; -import io.github.freya022.botcommands.internal.core.exceptions.InternalException; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; -import net.dv8tion.jda.api.utils.Timestamp; -import org.jetbrains.annotations.ApiStatus; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - -import java.util.Locale; -import java.util.Set; -import java.util.stream.Collectors; - -import static io.github.freya022.botcommands.api.localization.Localization.Entry.entry; - -/** - * Helper class to translate framework-specific messages. - * - *

The default values are contained in the {@code resources}, at {@code /bc_localization/DefaultMessages-default.json}. - * - *

You may change the default values by: - *

- * - *

You can always customize: - *

- * Most of the time it's easier to just add your new localization files in {@code /bc_localization}. - * - *

The localization paths must not be changed, the templates can have their values in any order, - * use different format specifiers, but need to keep the same names. - * - *

Refer to {@link Localization} for more details. - * - * @see Localization - * - * @deprecated This has been replaced by {@link io.github.freya022.botcommands.api.core.messages.DefaultBotCommandsMessages DefaultBotCommandsMessages} - */ -@NullMarked -@Deprecated(since = "3.1.0-beta.1", forRemoval = true) -public final class DefaultMessages { - private final Localization localization; - - /** - * THIS IS NOT A PUBLIC CONSTRUCTOR - */ - @ApiStatus.Internal - public DefaultMessages(LocalizationService localizationService, Locale locale) { - var localization = localizationService.getInstance("DefaultMessages", locale); - if (localization == null) { - final var mappingProviders = localizationService.getMappingProviders(); - final var mappingReaders = localizationService.getMappingReaders(); - throw new InternalException("Could not load DefaultMessages, providers: " + mappingProviders + ", readers: " + mappingReaders); - } - this.localization = localization; - } - - private LocalizationTemplate getLocalizationTemplate(String path) { - final LocalizationTemplate template = getLocalizationTemplateOrNull(path); - if (template == null) { - throw new InternalException("Localization template for default messages '" + path + "' could not be found, available keys: " + localization.getKeys()); - } - - return template; - } - - @Nullable - private LocalizationTemplate getLocalizationTemplateOrNull(String path) { - return localization.get(path); - } - - /** - * @return The localized permission, or {@link Permission#getName()} if the translation is missing. - */ - public String getPermission(Permission permission) { - final LocalizationTemplate localizationTemplate = getLocalizationTemplateOrNull("permissions." + permission.name()); - return localizationTemplate != null ? localizationTemplate.localize() : permission.getName(); - } - - /** - * @return Message to display when an uncaught exception occurs - */ - public String getGeneralErrorMsg() { - return getLocalizationTemplate("general_error_message").localize(); - } - - /** - * @return Message to display when the user does not have enough permissions - */ - public String getUserPermErrorMsg(Set permissions) { - final String localizedPermissions = permissions.stream().map(this::getPermission).collect(Collectors.joining(", ")); - return getLocalizationTemplate("user.perm.error.message").localize(entry("permissions", localizedPermissions)); - } - - /** - * @return Message to display when the bot does not have enough permissions - */ - public String getBotPermErrorMsg(Set permissions) { - final String localizedPermissions = permissions.stream().map(this::getPermission).collect(Collectors.joining(", ")); - return getLocalizationTemplate("bot.perm.error.message").localize(entry("permissions", localizedPermissions)); - } - - /** - * @return Message to display when the command is only usable by the owner - */ - public String getOwnerOnlyErrorMsg() { - return getLocalizationTemplate("owner.only.error.message").localize(); - } - - /** - * @return Message to display when the command is on per-user rate limit - */ - public String getUserRateLimitMsg(Timestamp timestamp) { - return getLocalizationTemplate("user.rate_limit.message").localize(entry("delay", timestamp)); - } - - /** - * @return Message to display when the command is on per-channel rate limit - */ - public String getChannelRateLimitMsg(Timestamp timestamp) { - return getLocalizationTemplate("channel.rate_limit.message").localize(entry("delay", timestamp)); - } - - /** - * @return Message to display when the command is on per-guild rate limit - */ - public String getGuildRateLimitMsg(Timestamp timestamp) { - return getLocalizationTemplate("guild.rate_limit.message").localize(entry("delay", timestamp)); - } - - /** - * @return Message to display when application commands are not loaded on the guild yet - */ - public String getApplicationCommandsNotAvailableMsg() { - return getLocalizationTemplate("application_commands_not_available").localize(); - } - - /** - * @return Message to display when the command is not found - */ - public String getCommandNotFoundMsg(String suggestions) { - return getLocalizationTemplate("command.not.found.message").localize(entry("suggestions", suggestions)); - } - - /** - * @return Message to display when a channel parameter could not be resolved - */ - public String getResolverChannelNotFoundMsg() { - return getLocalizationTemplate("resolver.channel.not_found.message").localize(); - } - - /** - * @return Message to display when a channel parameter could not be resolved - */ - public String getResolverChannelMissingAccessMsg(String channelMention) { - return getLocalizationTemplate("resolver.channel.missing_access.message").localize(entry("channel_mention", channelMention)); - } - - /** - * @return Message to display when a user parameter could not be resolved - */ - public String getResolverUserNotFoundMsg() { - return getLocalizationTemplate("resolver.user.not_found.message").localize(); - } - - /** - * @return Message to display when a slash command option is unresolvable (only in slash command interactions) - */ - public String getSlashCommandUnresolvableOptionMsg(String parameterName) { - return getLocalizationTemplate("slash.command.unresolvable.option.message").localize( - entry("optionName", parameterName) - ); - } - - /** - * @return Message to display when a User's DMs are closed (when sending help content for example) - */ - public String getClosedDMErrorMsg() { - return getLocalizationTemplate("closed.dm.error.message").localize(); - } - - /** - * @return Message to display when a command is used in a non-NSFW {@link GuildMessageChannel} - */ - public String getNSFWOnlyErrorMsg() { - return getLocalizationTemplate("nsfw.only.error.message").localize(); - } - - /** - * @return Message to display when a user tries to use a component it cannot interact with - */ - public String getComponentNotAllowedErrorMsg() { - return getLocalizationTemplate("component.not.allowed.error.message").localize(); - } - - /** - * @return Message to display when a user tries to use a component which has reached timeout while the bot was offline - */ - public String getComponentExpiredErrorMsg() { - return getLocalizationTemplate("component.expired.error.message").localize(); - } - - /** - * @return Message to display when a user tries to use a modal which has reached timeout - */ - public String getModalExpiredErrorMsg() { - return getLocalizationTemplate("modal.expired.error.message").localize(); - } -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/commands/application/ApplicationCommand.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/commands/application/ApplicationCommand.kt deleted file mode 100644 index 6fb299881..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/commands/application/ApplicationCommand.kt +++ /dev/null @@ -1,43 +0,0 @@ -package io.github.freya022.botcommands.api.commands.application - -import io.github.freya022.botcommands.api.commands.CommandPath -import io.github.freya022.botcommands.api.commands.application.context.annotations.JDAMessageCommand -import io.github.freya022.botcommands.api.commands.application.context.annotations.JDAUserCommand -import io.github.freya022.botcommands.api.commands.application.slash.annotations.JDASlashCommand -import io.github.freya022.botcommands.api.core.reflect.ParameterType -import io.github.freya022.botcommands.internal.utils.throwArgument -import net.dv8tion.jda.api.entities.Guild -import net.dv8tion.jda.api.interactions.commands.Command - -/** - * Base class for **annotated** application commands such as slash / context commands. - * - * You are not required to use this if you use the application command provider interfaces. - * - * @see JDASlashCommand @JDASlashCommand - * @see JDAMessageCommand @JDAMessageCommand - * @see JDAUserCommand @JDAUserCommand - * - * @see SlashOptionChoiceProvider - */ -@Deprecated(message = "This superclass is no longer mandatory, if you override methods from it, implement them using their respective interfaces") -abstract class ApplicationCommand : SlashOptionChoiceProvider, ApplicationGeneratedValueSupplierProvider { - override fun getOptionChoices(guild: Guild?, commandPath: CommandPath, optionName: String): List { - return emptyList() - } - - override fun getGeneratedValueSupplier( - guild: Guild?, - commandId: String?, commandPath: CommandPath, - optionName: String, parameterType: ParameterType - ): ApplicationGeneratedValueSupplier { - val errorStr = buildString { - append("Option '$optionName' in command path '${commandPath.fullPath}'") - if (commandId != null) append(" (id '$commandId')") - if (guild != null) append(" in guild '${guild.name}' (id ${guild.id})") - append(" is a generated option but no generated value supplier has been given") - } - - throwArgument(errorStr) - } -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BApplicationConfig.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BApplicationConfig.kt index a99f9dbfa..ab5d23bdc 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BApplicationConfig.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BApplicationConfig.kt @@ -19,7 +19,6 @@ import io.github.freya022.botcommands.api.localization.readers.JacksonLocalizati import io.github.freya022.botcommands.api.localization.readers.LocalizationMapReader import io.github.freya022.botcommands.internal.core.config.ConfigDSL import io.github.freya022.botcommands.internal.core.config.ConfigurationValue -import io.github.freya022.botcommands.internal.core.config.DeprecatedValue import io.github.freya022.botcommands.internal.core.exceptions.internalErrorMessage import io.github.freya022.botcommands.internal.utils.lazyWritable import io.github.freya022.botcommands.internal.utils.throwInternal @@ -48,18 +47,6 @@ interface BApplicationConfigProps { @ConfigurationValue(path = "botcommands.application.enable", defaultValue = "true") val enable: Boolean - /** - * If not empty, only these guilds will have their application commands updated. - * - * Existing commands won't be removed in other guilds, global commands will still be updated. - * - * Spring property: `botcommands.application.slashGuildIds` - */ - @Deprecated("Replaced by 'guildsToUpdate'", replaceWith = ReplaceWith("guildToUpdate")) - @DeprecatedValue("Replaced by 'guildsToUpdate'", replacement = "botcommands.application.slashGuildIds") - @ConfigurationValue(path = "botcommands.application.slashGuildIds") - val slashGuildIds: List get() = guildsToUpdate - /** * If not empty, application commands will only be updated in these guilds. * @@ -164,8 +151,6 @@ interface BApplicationConfigProps { class BApplicationConfigBuilder internal constructor() : BApplicationConfigProps { @set:JvmName("enable") override var enable: Boolean = true - @Deprecated("Replaced by 'guildsToUpdate'", replaceWith = ReplaceWith("guildToUpdate")) - override val slashGuildIds: MutableList get() = guildsToUpdate override val guildsToUpdate: MutableList = mutableListOf() override val testGuildIds: MutableList = mutableListOf() @set:DevConfig diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BConfig.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BConfig.kt index 9162d7c21..86eae9ccb 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BConfig.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/config/BConfig.kt @@ -9,14 +9,11 @@ import io.github.freya022.botcommands.api.core.requests.PriorityGlobalRestRateLi import io.github.freya022.botcommands.api.core.service.ClassGraphProcessor import io.github.freya022.botcommands.api.core.service.annotations.InjectedService import io.github.freya022.botcommands.api.core.utils.* -import io.github.freya022.botcommands.api.core.waiter.EventWaiter import io.github.freya022.botcommands.internal.core.config.ConfigDSL import io.github.freya022.botcommands.internal.core.config.ConfigurationValue -import io.github.freya022.botcommands.internal.core.config.DeprecatedValue import io.github.freya022.botcommands.internal.utils.putIfAbsentOrThrow import io.github.freya022.botcommands.internal.utils.throwInternal import io.github.oshai.kotlinlogging.KotlinLogging -import net.dv8tion.jda.api.events.Event import net.dv8tion.jda.api.requests.GatewayIntent import net.dv8tion.jda.api.requests.RestRateLimiter import net.dv8tion.jda.api.utils.messages.MessageCreateData @@ -112,18 +109,6 @@ interface BConfigProps { @ConfigurationValue(path = "botcommands.core.ignoredIntents") val ignoredIntents: Set - /** - * Events for which the [event waiter][EventWaiter] must ignore intent requirements. - * - * If not ignored, the event would still be being listened to, but a warning would have been logged. - * - * Spring property: `botcommands.core.ignoredEventIntents` - */ - @Deprecated("Replaced by EventWaiterBuilder.ignoreMissingIntents()") - @DeprecatedValue("Replaced by EventWaiterBuilder.ignoreMissingIntents()") - @ConfigurationValue(path = "botcommands.core.ignoredEventIntents", type = "java.util.Set>") - val ignoredEventIntents: Set> - /** * Suppresses warnings about the default [RestRateLimiter] being used for large bots. * @@ -179,9 +164,6 @@ class BConfigBuilder : BConfigProps { override val ignoredIntents: MutableSet = enumSetOf() - @Deprecated("Replaced by EventWaiterBuilder.ignoreMissingIntents()") - override val ignoredEventIntents: MutableSet> = hashSetOf() - override var ignoreRestRateLimiter: Boolean = false override val classGraphProcessors: MutableList = arrayListOf() @@ -356,8 +338,6 @@ class BConfigBuilder : BConfigProps { override val disableExceptionsInDMs = this@BConfigBuilder.disableExceptionsInDMs override val enableOwnerBypass = this@BConfigBuilder.enableOwnerBypass override val ignoredIntents = this@BConfigBuilder.ignoredIntents.toImmutableSet() - @Suppress("DEPRECATION", "OVERRIDE_DEPRECATION") - override val ignoredEventIntents = this@BConfigBuilder.ignoredEventIntents.toImmutableSet() override val ignoreRestRateLimiter = this@BConfigBuilder.ignoreRestRateLimiter override val classGraphProcessors = this@BConfigBuilder.classGraphProcessors.toImmutableList() override val enableShutdownHook = this@BConfigBuilder.enableShutdownHook diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/messages/BotCommandsMessagesFactory.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/messages/BotCommandsMessagesFactory.kt index 1cfaa5f56..2e309b137 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/messages/BotCommandsMessagesFactory.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/messages/BotCommandsMessagesFactory.kt @@ -1,9 +1,6 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.api.core.messages import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider import net.dv8tion.jda.api.events.message.MessageReceivedEvent @@ -11,8 +8,7 @@ import net.dv8tion.jda.api.interactions.Interaction import java.util.* /** - * Factory of [BotCommandsMessages], the default implementation is [DefaultBotCommandsMessagesFactory], or, - * if a non-default [DefaultMessagesFactory] exists, an adapter is used. + * Factory of [BotCommandsMessages], the default implementation is [DefaultBotCommandsMessagesFactory]. * * ### Complete customization * @@ -40,4 +36,4 @@ interface BotCommandsMessagesFactory { * By default, this uses [UserLocaleProvider] to get the locale. */ fun get(event: Interaction): BotCommandsMessages -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/service/DefaultServiceContainer.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/service/DefaultServiceContainer.kt deleted file mode 100644 index 048071a10..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/service/DefaultServiceContainer.kt +++ /dev/null @@ -1,4 +0,0 @@ -package io.github.freya022.botcommands.api.core.service - -@Deprecated("Renamed to BCServiceContainer", ReplaceWith("BCServiceContainer")) -interface DefaultServiceContainer : BCServiceContainer diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/waiter/EventWaiter.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/waiter/EventWaiter.kt index b652e9ef2..16a708ecb 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/waiter/EventWaiter.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/waiter/EventWaiter.kt @@ -1,6 +1,5 @@ package io.github.freya022.botcommands.api.core.waiter -import io.github.freya022.botcommands.api.core.config.BConfigBuilder import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService import kotlinx.coroutines.future.await import net.dv8tion.jda.api.JDA @@ -45,8 +44,6 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent * LOGGER.error("Error waiting for event", e); * } * ``` - * - * @see BConfigBuilder.ignoredEventIntents */ @InterfacedService(acceptMultiple = false) interface EventWaiter { diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/DefaultMessagesFactory.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/DefaultMessagesFactory.kt deleted file mode 100644 index 0a52848b2..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/DefaultMessagesFactory.kt +++ /dev/null @@ -1,41 +0,0 @@ -@file:Suppress("removal", "DEPRECATION") - -package io.github.freya022.botcommands.api.localization - -import io.github.freya022.botcommands.api.core.service.annotations.BService -import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService -import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider -import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider -import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.Interaction -import java.util.* - -/** - * Factory for [DefaultMessages] instances, using locales from various sources. - * - * **Usage:** Register your instance as a service with [@BService][BService]. - * - * @see InterfacedService @InterfacedService - */ -@Deprecated("Replaced by BotCommandsMessagesFactory") -@InterfacedService(acceptMultiple = false) -interface DefaultMessagesFactory { - /** - * Retrieves a [DefaultMessages] instance for the given locale. - */ - fun get(locale: Locale): DefaultMessages - - /** - * Retrieves a [DefaultMessages] instance, with the locale derived from this event. - * - * By default, this uses [TextCommandLocaleProvider] to get the locale. - */ - fun get(event: MessageReceivedEvent): DefaultMessages - - /** - * Retrieves a [DefaultMessages] instance, with the locale derived from this interaction. - * - * By default, this uses [UserLocaleProvider] to get the locale. - */ - fun get(event: Interaction): DefaultMessages -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/LocalizableAction.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/LocalizableAction.kt index a5d1edf8d..b6538cc4c 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/LocalizableAction.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/LocalizableAction.kt @@ -6,7 +6,6 @@ import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFacto import io.github.freya022.botcommands.api.localization.context.LocalizationContext import io.github.freya022.botcommands.api.localization.context.PairEntry import io.github.freya022.botcommands.api.localization.context.mapToEntries -import net.dv8tion.jda.api.interactions.DiscordLocale import java.util.* /** @@ -40,15 +39,6 @@ interface LocalizableAction { */ fun getLocalizationContext(bundleName: String, pathPrefix: String?): LocalizationContext - /** - * Retrieves a [DefaultMessages] instance, using a locale suitable for messages sent to the user. - * - * @see DefaultMessagesFactory - */ - @Suppress("DEPRECATION", "removal") - @Deprecated("Replaced with getBotCommandsMessages()") - fun getDefaultMessages(): DefaultMessages - /** * Retrieves a [BotCommandsMessages] instance, using a locale suitable for messages sent to the user. * @@ -79,38 +69,7 @@ interface LocalizableAction { * - If the template requires an argument that was not passed to [entries] */ fun getLocalizedMessage(locale: Locale, localizationPath: String, vararg entries: Localization.Entry): String - - /** - * Returns the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param locale The locale to translate the message to - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][localizationPrefix] unless starting with `/` - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - fun getLocalizedMessage(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): String = - getLocalizedMessage(locale.toLocale(), localizationPath, *entries) } fun LocalizableAction.getLocalizedMessage(locale: Locale, localizationPath: String, vararg entries: PairEntry): String = getLocalizedMessage(locale, localizationPath, *entries.mapToEntries()) - -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableAction.getLocalizedMessage(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String = - getLocalizedMessage(locale, localizationPath, *entries.mapToEntries()) diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/AppLocalizationContext.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/AppLocalizationContext.kt index 039fe9dd4..f073d25dd 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/AppLocalizationContext.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/AppLocalizationContext.kt @@ -1,12 +1,9 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.api.localization.context import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.annotations.LocalizationBundle import io.github.freya022.botcommands.api.localization.interaction.GuildLocaleProvider import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import java.util.* import javax.annotation.CheckReturnValue @@ -45,10 +42,6 @@ interface AppLocalizationContext : TextLocalizationContext { //User locale is always provided in interactions val userLocale: Locale - @Deprecated("Use the Locale overload") - @CheckReturnValue - override fun withGuildLocale(guildLocale: DiscordLocale?): AppLocalizationContext - @CheckReturnValue override fun withGuildLocale(guildLocale: Locale?): AppLocalizationContext diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/LocalizationContext.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/LocalizationContext.kt index c0b3d93e3..e2ed34778 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/LocalizationContext.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/context/LocalizationContext.kt @@ -1,5 +1,3 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.api.localization.context import io.github.freya022.botcommands.api.commands.text.BaseCommandEvent @@ -17,7 +15,6 @@ import net.dv8tion.jda.api.entities.Guild import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import net.dv8tion.jda.api.interactions.InteractionHook import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback @@ -72,15 +69,6 @@ interface LocalizationContext { */ val localizationPrefix: String? - /** - * Returns a new [TextLocalizationContext] with the specified guild locale. - * - * @param guildLocale The guild locale to use, or `null` to remove it - */ - @Deprecated("Use the Locale overload") - @CheckReturnValue - fun withGuildLocale(guildLocale: DiscordLocale?): TextLocalizationContext - /** * Returns a new [TextLocalizationContext] with the specified guild locale. * @@ -89,15 +77,6 @@ interface LocalizationContext { @CheckReturnValue fun withGuildLocale(guildLocale: Locale?): TextLocalizationContext - /** - * Returns a new [AppLocalizationContext] with the specified user locale. - * - * @param userLocale The user locale to use, or `null` to remove it - */ - @Deprecated("Use the Locale overload") - @CheckReturnValue - fun withUserLocale(userLocale: DiscordLocale?): AppLocalizationContext - /** * Returns a new [AppLocalizationContext] with the specified user locale. * @@ -131,18 +110,6 @@ interface LocalizationContext { @CheckReturnValue fun switchBundle(localizationBundle: String): LocalizationContext - /** - * Localizes the provided path, with the provided locale. - * - * @param locale The [DiscordLocale] to use when fetching the localization bundle - * @param localizationPath The path of the localization template, - * prefixed with [localizationPrefix][LocalizationContext.localizationPrefix] unless starting with `/` - * @param entries The entries to fill the template with - */ - @Deprecated("Use the Locale overload") - fun localize(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): String - = localize(locale.toLocale(), localizationPath, *entries) - /** * Localizes the provided path, with the provided locale. * @@ -153,18 +120,6 @@ interface LocalizationContext { */ fun localize(locale: Locale, localizationPath: String, vararg entries: Localization.Entry): String - /** - * Localizes the provided path, with the provided locale, or returns `null` if the path does not exist. - * - * @param locale The [DiscordLocale] to use when fetching the localization bundle - * @param localizationPath The path of the localization template, - * prefixed with [localizationPrefix][LocalizationContext.localizationPrefix] unless starting with `/` - * @param entries The entries to fill the template with - */ - @Deprecated("Use the Locale overload") - fun localizeOrNull(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): String? - = localizeOrNull(locale.toLocale(), localizationPath, *entries) - /** * Localizes the provided path, with the provided locale, or returns `null` if the path does not exist. * @@ -267,81 +222,6 @@ interface LocalizationContext { } companion object { - @JvmStatic - @JvmOverloads - @Deprecated("Replaced by builder") - fun create( - context: BContext, - localizationBundle: String, - localizationPrefix: String? = null, - guildLocale: DiscordLocale? = null, - userLocale: DiscordLocale? = null - ): AppLocalizationContext { - return LocalizationContextImpl( - context.getService(), - localizationBundle, - localizationPrefix, - guildLocale?.toProvider(), - userLocale?.toProvider() - ) - } - - @JvmStatic - @JvmOverloads - @Deprecated("Replaced by builder") - fun create( - localizationService: LocalizationService, - localizationBundle: String, - localizationPrefix: String? = null, - guildLocale: DiscordLocale? = null, - userLocale: DiscordLocale? = null - ): AppLocalizationContext { - return LocalizationContextImpl( - localizationService, - localizationBundle, - localizationPrefix, - guildLocale?.toProvider(), - userLocale?.toProvider() - ) - } - - @JvmStatic - @JvmOverloads - @Deprecated("Replaced by builder") - fun fromLocaleProviders( - context: BContext, - event: Interaction, - localizationBundle: String, - localizationPrefix: String? = null - ): AppLocalizationContext { - return LocalizationContextImpl( - context.getService(), - localizationBundle, - localizationPrefix, - lazy { context.getService().getLocale(event) }, - lazy { context.getService().getLocale(event) }, - ) - } - - @JvmStatic - @JvmOverloads - @Deprecated("Replaced by builder") - fun fromLocaleProviders( - context: BContext, - event: MessageReceivedEvent, - localizationBundle: String, - localizationPrefix: String? = null, - userLocale: DiscordLocale? = null, - ): TextLocalizationContext { - return LocalizationContextImpl( - context.getService(), - localizationBundle, - localizationPrefix, - lazy { context.getService().getLocale(event) }, - userLocale?.toProvider(), - ) - } - /** * Creates a new builder, using a [LocalizationService] retrieved from the provided context, * and the specified bundle name, from which the strings will be retrieved from. @@ -359,8 +239,6 @@ interface LocalizationContext { fun builder(localizationService: LocalizationService, localizationBundle: String): Builder { return Builder(localizationService, localizationBundle) } - - private fun DiscordLocale.toProvider(): Lazy = lazyOf(this.toLocale()) } } @@ -368,18 +246,6 @@ internal fun Array.mapToEntries() = Array(this.size) { Localization.Entry(this[it].first, this[it].second) } -/** - * Localizes the provided path, with the provided locale. - * - * @param locale The [DiscordLocale] to use when fetching the localization bundle - * @param localizationPath The path of the localization template, - * prefixed with [localizationPrefix][LocalizationContext.localizationPrefix] unless starting with `/` - * @param entries The entries to fill the template with - */ -@Deprecated("Use the Locale overload") -fun LocalizationContext.localize(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String = - localize(locale, localizationPath, *entries.mapToEntries()) - /** * Localizes the provided path, with the provided locale. * @@ -391,18 +257,6 @@ fun LocalizationContext.localize(locale: DiscordLocale, localizationPath: String fun LocalizationContext.localize(locale: Locale, localizationPath: String, vararg entries: PairEntry): String = localize(locale, localizationPath, *entries.mapToEntries()) -/** - * Localizes the provided path, with the provided locale, or returns `null` if the path does not exist. - * - * @param locale The [DiscordLocale] to use when fetching the localization bundle - * @param localizationPath The path of the localization template, - * prefixed with [localizationPrefix][LocalizationContext.localizationPrefix] unless starting with `/` - * @param entries The entries to fill the template with - */ -@Deprecated("Use the Locale overload") -fun LocalizationContext.localizeOrNull(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String? = - localizeOrNull(locale, localizationPath, *entries.mapToEntries()) - /** * Localizes the provided path, with the provided locale, or returns `null` if the path does not exist. * diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/GuildLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/GuildLocaleProvider.kt index ba7ae8797..91c789ab5 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/GuildLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/GuildLocaleProvider.kt @@ -4,18 +4,15 @@ import io.github.freya022.botcommands.api.core.service.annotations.BService import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService import io.github.freya022.botcommands.api.localization.context.AppLocalizationContext import io.github.freya022.botcommands.api.localization.context.TextLocalizationContext -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import java.util.* /** - * Provides the locale of a guild in a Discord interaction, - * may be useful if the guild has set its own locale, for example. + * Provides the locale of a guild in a Discord interaction. * - * It is recommended to override both [getDiscordLocale] and [getLocale] for best results, - * when using localization in events, and in [AppLocalizationContext]. + * You may provide a custom implementation, for example, if a guild's locale depends on some external setting. * - * This returns [Interaction.getGuildLocale] by default. + * This returns [interaction.getGuildLocale().toLocale()][Interaction.getGuildLocale] by default. * * ### Usage * Register your instance as a service with [@BService][BService]. @@ -26,11 +23,5 @@ import java.util.* */ @InterfacedService(acceptMultiple = false) interface GuildLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - fun getDiscordLocale(interaction: Interaction): DiscordLocale = - throw UnsupportedOperationException("'getLocale' needs to be implemented instead") - - @Suppress("DEPRECATION") - fun getLocale(interaction: Interaction): Locale = - getDiscordLocale(interaction).toLocale() + fun getLocale(interaction: Interaction): Locale } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableEditCallback.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableEditCallback.kt index 8ca944ae7..098a217bc 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableEditCallback.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableEditCallback.kt @@ -4,7 +4,6 @@ import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.context.PairEntry import io.github.freya022.botcommands.api.localization.context.mapToEntries -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.requests.restaction.interactions.MessageEditCallbackAction import java.util.* import javax.annotation.CheckReturnValue @@ -74,32 +73,6 @@ interface LocalizableEditCallback { @CheckReturnValue fun editGuild(localizationPath: String, vararg entries: Localization.Entry): MessageEditCallbackAction - /** - * Edits the original message with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableInteraction.localizationPrefix] unless starting with `/` - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun editLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): MessageEditCallbackAction = - editLocalized(locale.toLocale(), localizationPath, *entries) - /** * Edits the original message with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -181,32 +154,6 @@ fun LocalizableEditCallback.editUser(localizationPath: String, vararg entries: P fun LocalizableEditCallback.editGuild(localizationPath: String, vararg entries: PairEntry) = editGuild(localizationPath, *entries.mapToEntries()) -/** - * Edits the original message with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableInteraction.localizationPrefix] unless starting with `/` - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableEditCallback.editLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - editLocalized(locale, localizationPath, *entries.mapToEntries()) - /** * Edits the original message with the localized message at the following [path][localizationPath], * using the provided locale and parameters. diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableInteractionHook.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableInteractionHook.kt index cfb76251d..2f2b7d314 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableInteractionHook.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableInteractionHook.kt @@ -5,7 +5,6 @@ import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.context.PairEntry import io.github.freya022.botcommands.api.localization.context.mapToEntries import net.dv8tion.jda.api.entities.Message -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.InteractionHook import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction @@ -81,31 +80,6 @@ interface LocalizableInteractionHook : InteractionHook { @CheckReturnValue fun sendGuild(localizationPath: String, vararg entries: Localization.Entry): WebhookMessageCreateAction - /** - * Sends a follow-up with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, will be prefixed with [LocalizableInteraction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun sendLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): WebhookMessageCreateAction = - sendLocalized(locale.toLocale(), localizationPath, *entries) - /** * Sends a follow-up with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -183,31 +157,6 @@ interface LocalizableInteractionHook : InteractionHook { @CheckReturnValue fun editGuild(localizationPath: String, vararg entries: Localization.Entry): WebhookMessageEditAction - /** - * Edits the original message with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, will be prefixed with [LocalizableInteraction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun editLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): WebhookMessageEditAction = - editLocalized(locale.toLocale(), localizationPath, *entries) - /** * Edits the original message with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -286,31 +235,6 @@ fun LocalizableInteractionHook.sendUser(localizationPath: String, vararg entries fun LocalizableInteractionHook.sendGuild(localizationPath: String, vararg entries: PairEntry) = sendGuild(localizationPath, *entries.mapToEntries()) -/** - * Sends a follow-up with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, will be prefixed with [LocalizableInteraction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableInteractionHook.sendLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - sendLocalized(locale, localizationPath, *entries.mapToEntries()) - /** * Sends a follow-up with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -388,31 +312,6 @@ fun LocalizableInteractionHook.editUser(localizationPath: String, vararg entries fun LocalizableInteractionHook.editGuild(localizationPath: String, vararg entries: PairEntry) = editGuild(localizationPath, *entries.mapToEntries()) -/** - * Edits the original message with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, will be prefixed with [LocalizableInteraction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableInteractionHook.editLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - editLocalized(locale, localizationPath, *entries.mapToEntries()) - /** * Edits the original message with the localized message at the following [path][localizationPath], * using the provided locale and parameters. diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableReplyCallback.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableReplyCallback.kt index 8dbca4697..85d20d09d 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableReplyCallback.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/LocalizableReplyCallback.kt @@ -4,7 +4,6 @@ import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.context.PairEntry import io.github.freya022.botcommands.api.localization.context.mapToEntries -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction import java.util.* import javax.annotation.CheckReturnValue @@ -74,32 +73,6 @@ interface LocalizableReplyCallback { @CheckReturnValue fun replyGuild(localizationPath: String, vararg entries: Localization.Entry): ReplyCallbackAction - /** - * Replies with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableInteraction.localizationPrefix] unless starting with `/` - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun replyLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): ReplyCallbackAction = - replyLocalized(locale.toLocale(), localizationPath, *entries) - /** * Replies with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -181,32 +154,6 @@ fun LocalizableReplyCallback.replyUser(localizationPath: String, vararg entries: fun LocalizableReplyCallback.replyGuild(localizationPath: String, vararg entries: PairEntry) = replyGuild(localizationPath, *entries.mapToEntries()) -/** - * Replies with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableInteraction.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableInteraction.localizationPrefix] unless starting with `/` - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableInteraction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableReplyCallback.replyLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - replyLocalized(locale, localizationPath, *entries.mapToEntries()) - /** * Replies with the localized message at the following [path][localizationPath], * using the provided locale and parameters. diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/UserLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/UserLocaleProvider.kt index 6bb945de8..8a5133070 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/UserLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/interaction/UserLocaleProvider.kt @@ -3,18 +3,15 @@ package io.github.freya022.botcommands.api.localization.interaction import io.github.freya022.botcommands.api.core.service.annotations.BService import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService import io.github.freya022.botcommands.api.localization.context.AppLocalizationContext -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import java.util.* /** - * Provides the locale of a user in a Discord interaction, - * may be useful if the user has set its own locale, for example. + * Provides the locale of a user in a Discord interaction. * - * It is recommended to override both [getDiscordLocale] and [getLocale] for best results, - * when using localization in events, and in [AppLocalizationContext]. + * You may provide a custom implementation, for example, if a user's locale depends on some external setting. * - * This returns [Interaction.getUserLocale] by default. + * This returns [interaction.getUserLocale().toLocale()][Interaction.getUserLocale] by default. * * ### Usage * Register your instance as a service with [@BService][BService]. @@ -24,11 +21,5 @@ import java.util.* */ @InterfacedService(acceptMultiple = false) interface UserLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - fun getDiscordLocale(interaction: Interaction): DiscordLocale = - throw UnsupportedOperationException("'getLocale' needs to be implemented instead") - - @Suppress("DEPRECATION") - fun getLocale(interaction: Interaction): Locale = - getDiscordLocale(interaction).toLocale() + fun getLocale(interaction: Interaction): Locale } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/LocalizableTextCommand.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/LocalizableTextCommand.kt index 9a294ba50..acab8d1d9 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/LocalizableTextCommand.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/LocalizableTextCommand.kt @@ -7,7 +7,6 @@ import io.github.freya022.botcommands.api.localization.context.PairEntry import io.github.freya022.botcommands.api.localization.context.TextLocalizationContext import io.github.freya022.botcommands.api.localization.context.mapToEntries import net.dv8tion.jda.api.entities.Guild -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.requests.restaction.MessageCreateAction import java.util.* import javax.annotation.CheckReturnValue @@ -116,58 +115,6 @@ interface LocalizableTextCommand : LocalizableAction { @CheckReturnValue fun replyGuild(localizationPath: String, vararg entries: Localization.Entry): MessageCreateAction - /** - * Responds with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableAction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableAction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun respondLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): MessageCreateAction = - respondLocalized(locale.toLocale(), localizationPath, *entries) - - /** - * Replies with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableAction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableAction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ - @Deprecated("Pass a Locale instead") - @CheckReturnValue - fun replyLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): MessageCreateAction = - replyLocalized(locale.toLocale(), localizationPath, *entries) - /** * Responds with the localized message at the following [path][localizationPath], * using the provided locale and parameters. @@ -301,58 +248,6 @@ fun LocalizableTextCommand.respondGuild(localizationPath: String, vararg entries fun LocalizableTextCommand.replyGuild(localizationPath: String, vararg entries: PairEntry) = replyGuild(localizationPath, *entries.mapToEntries()) -/** - * Responds with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableTextCommand.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableAction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableAction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableTextCommand.respondLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - respondLocalized(locale, localizationPath, *entries.mapToEntries()) - -/** - * Replies with the localized message at the following [path][localizationPath], - * using the provided locale and parameters. - * - * ### Bundle resolution - * The bundle used is either the [defined bundle][LocalizableTextCommand.localizationBundle] - * or one of the [registered bundles][BLocalizationConfig.responseBundles]. - * - * The locale of the bundle is the best available, - * for example, if `fr_FR` is not available, then `fr` will be used, - * and otherwise, the root bundle (without any suffix) will be used. - * - * @param localizationPath The path of the message to translate, - * will be prefixed with [localizationPrefix][LocalizableAction.localizationPrefix] - * @param entries The values replacing arguments of the localization template - * - * @throws IllegalArgumentException If: - * - [localizationBundle][LocalizableAction.localizationBundle] is set, but the bundle doesn't exist - * - No [registered bundle][BLocalizationConfig.responseBundles] containing the path could be found - * - If the template requires an argument that was not passed to [entries] - */ -@Suppress("DEPRECATION") -@Deprecated("Pass a Locale instead") -fun LocalizableTextCommand.replyLocalized(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry) = - replyLocalized(locale, localizationPath, *entries.mapToEntries()) - /** * Responds with the localized message at the following [path][localizationPath], * using the provided locale and parameters. diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/TextCommandLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/TextCommandLocaleProvider.kt index 17fd289ef..2766b1b36 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/TextCommandLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/text/TextCommandLocaleProvider.kt @@ -2,20 +2,16 @@ package io.github.freya022.botcommands.api.localization.text import io.github.freya022.botcommands.api.core.service.annotations.BService import io.github.freya022.botcommands.api.core.service.annotations.InterfacedService -import io.github.freya022.botcommands.api.localization.context.TextLocalizationContext import net.dv8tion.jda.api.entities.Guild import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.DiscordLocale import java.util.* /** - * Provides the locale to be used for localizing text command responses, - * may be useful if the user has set its own locale, for example. + * Provides the locale to be used for localizing text command responses. * - * It is recommended to override both [getDiscordLocale] and [getLocale] for best results, - * when using localization in events, and in [TextLocalizationContext]. + * You may provide a custom implementation, for example, if a guild/user's locale depends on some external setting. * - * This returns [Guild.getLocale] by default. + * This returns [guild.getLocale().toLocale()][Guild.getLocale] by default. * * ### Usage * Register your instance as a service with [@BService][BService]. @@ -24,11 +20,5 @@ import java.util.* */ @InterfacedService(acceptMultiple = false) interface TextCommandLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - fun getDiscordLocale(event: MessageReceivedEvent): DiscordLocale = - throw UnsupportedOperationException("'getLocale' needs to be implemented instead") - - @Suppress("DEPRECATION") - fun getLocale(event: MessageReceivedEvent): Locale = - getDiscordLocale(event).toLocale() + fun getLocale(event: MessageReceivedEvent): Locale } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/pagination/UsedComponentSet.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/pagination/UsedComponentSet.kt index 020359063..615fc852b 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/pagination/UsedComponentSet.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/pagination/UsedComponentSet.kt @@ -1,14 +1,12 @@ package io.github.freya022.botcommands.api.pagination import dev.freya02.botcommands.jda.ktx.components.findAll -import dev.freya02.botcommands.jda.ktx.components.toDefaultComponentTree import gnu.trove.set.hash.TIntHashSet import io.github.freya022.botcommands.api.components.Components import io.github.freya022.botcommands.api.components.IdentifiableComponent import io.github.freya022.botcommands.internal.utils.any import io.github.freya022.botcommands.internal.utils.reference import io.github.oshai.kotlinlogging.KotlinLogging -import net.dv8tion.jda.api.components.Component import net.dv8tion.jda.api.components.attribute.ICustomId import net.dv8tion.jda.api.components.tree.ComponentTree import kotlin.reflect.KProperty @@ -21,17 +19,6 @@ private val logger = KotlinLogging.logger { } class UsedComponentSet(private val componentsService: Components, private val cleanAfterRefresh: Boolean) { private lateinit var currentIds: TIntHashSet - @Deprecated( - message = "Replaced with setComponent(ComponentTree), if you have a message, you should get the ComponentTree directly from it", - replaceWith = ReplaceWith( - expression = "setComponents(components.toList().toDefaultComponentTree())", - imports = arrayOf("dev.freya02.botcommands.jda.ktx.components.toDefaultComponentTree") - ) - ) - fun setComponents(components: Iterable) { - return setComponents(components.toList().toDefaultComponentTree()) - } - fun setComponents(componentTree: ComponentTree<*>) { val newIds = TIntHashSet().apply { componentTree diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesDefaultMessagesAdapter.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesDefaultMessagesAdapter.kt deleted file mode 100644 index f7db992be..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesDefaultMessagesAdapter.kt +++ /dev/null @@ -1,103 +0,0 @@ -@file:Suppress("removal", "DEPRECATION") - -package io.github.freya022.botcommands.internal.core.messages.autoconfigure - -import io.github.freya022.botcommands.api.commands.application.slash.options.SlashCommandOption -import io.github.freya022.botcommands.api.commands.text.TopLevelTextCommandInfo -import io.github.freya022.botcommands.api.core.messages.BotCommandsMessages -import io.github.freya022.botcommands.api.localization.DefaultMessages -import net.dv8tion.jda.api.Permission -import net.dv8tion.jda.api.events.GenericEvent -import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent -import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent -import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent -import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload -import net.dv8tion.jda.api.utils.TimeFormat -import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder -import net.dv8tion.jda.api.utils.messages.MessageCreateData -import java.time.Instant - -internal class BotCommandsMessagesDefaultMessagesAdapter internal constructor( - private val defaultMessages: DefaultMessages, -) : BotCommandsMessages { - - override fun uncaughtException(event: GenericEvent): MessageCreateData { - return defaultMessages.generalErrorMsg.toMessage() - } - - override fun missingUserPermissions(event: GenericEvent, permissions: Set): MessageCreateData { - return defaultMessages.getUserPermErrorMsg(permissions).toMessage() - } - - override fun missingBotPermissions(event: GenericEvent, permissions: Set): MessageCreateData { - return defaultMessages.getBotPermErrorMsg(permissions).toMessage() - } - - override fun ownerOnly(event: GenericEvent): MessageCreateData { - return defaultMessages.ownerOnlyErrorMsg.toMessage() - } - - override fun userRateLimited(event: GenericEvent, deadline: Instant): MessageCreateData { - return defaultMessages.getUserRateLimitMsg(TimeFormat.RELATIVE.atInstant(deadline)).toMessage() - } - - override fun channelRateLimited(event: GenericEvent, deadline: Instant): MessageCreateData { - return defaultMessages.getChannelRateLimitMsg(TimeFormat.RELATIVE.atInstant(deadline)).toMessage() - } - - override fun guildRateLimited(event: GenericEvent, deadline: Instant): MessageCreateData { - return defaultMessages.getGuildRateLimitMsg(TimeFormat.RELATIVE.atInstant(deadline)).toMessage() - } - - override fun applicationCommandsNotAvailable(event: GenericCommandInteractionEvent): MessageCreateData { - return defaultMessages.applicationCommandsNotAvailableMsg.toMessage() - } - - override fun commandNotFound(event: MessageReceivedEvent, suggestions: Collection): MessageCreateData { - val suggestionsStr = suggestions.joinToString(separator = "**, **", prefix = "**", postfix = "**") { it.name } - return defaultMessages.getCommandNotFoundMsg(suggestionsStr).toMessage() - } - - override fun resolverChannelNotFound(event: GenericEvent, channelId: Long): MessageCreateData { - return defaultMessages.resolverChannelNotFoundMsg.toMessage() - } - - override fun resolverChannelMissingAccess(event: GenericEvent, channelId: Long): MessageCreateData { - return defaultMessages.getResolverChannelMissingAccessMsg("<#$channelId>").toMessage() - } - - override fun resolverUserNotFound(event: GenericEvent, userId: Long): MessageCreateData { - return defaultMessages.resolverUserNotFoundMsg.toMessage() - } - - override fun slashCommandUnresolvableOption(event: CommandInteractionPayload, option: SlashCommandOption): MessageCreateData { - return defaultMessages.getSlashCommandUnresolvableOptionMsg(option.discordName).toMessage() - } - - override fun closedDirectMessages(event: GenericEvent): MessageCreateData { - return defaultMessages.closedDMErrorMsg.toMessage() - } - - override fun nsfwOnly(event: GenericEvent): MessageCreateData { - return defaultMessages.nsfwOnlyErrorMsg.toMessage() - } - - override fun componentNotAllowed(event: GenericComponentInteractionCreateEvent): MessageCreateData { - return defaultMessages.componentNotAllowedErrorMsg.toMessage() - } - - override fun componentExpired(event: GenericComponentInteractionCreateEvent): MessageCreateData { - return defaultMessages.componentExpiredErrorMsg.toMessage() - } - - override fun modalExpired(event: ModalInteractionEvent): MessageCreateData { - return defaultMessages.modalExpiredErrorMsg.toMessage() - } - - private fun String.toMessage(): MessageCreateData = - MessageCreateBuilder() - .setContent(this) - .useComponentsV2(false) - .build() -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryAutoConfiguration.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryAutoConfiguration.kt index 8dfb17b53..60d59dd56 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryAutoConfiguration.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryAutoConfiguration.kt @@ -1,23 +1,14 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.internal.core.messages.autoconfigure -import io.github.classgraph.ClassGraph import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory import io.github.freya022.botcommands.api.core.messages.DefaultBotCommandsMessagesFactory import io.github.freya022.botcommands.api.core.service.annotations.ConditionalOnMissingService -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.LocalizationService import io.github.freya022.botcommands.api.localization.PermissionLocalization import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider import io.github.freya022.botcommands.internal.core.service.annotations.InternalAutoConfiguration import io.github.freya022.botcommands.internal.core.service.annotations.InternalAutoConfigurationBeanService -import io.github.freya022.botcommands.internal.localization.autoconfigure.FallbackDefaultMessagesFactory -import io.github.freya022.botcommands.internal.utils.classRef -import io.github.oshai.kotlinlogging.KotlinLogging - -private val logger = KotlinLogging.logger { } @InternalAutoConfiguration internal open class BotCommandsMessagesFactoryAutoConfiguration internal constructor() { @@ -25,18 +16,11 @@ internal open class BotCommandsMessagesFactoryAutoConfiguration internal constru @InternalAutoConfigurationBeanService @ConditionalOnMissingService(BotCommandsMessagesFactory::class) open fun botCommandsMessagesFactory( - defaultMessagesFactory: DefaultMessagesFactory, permissionLocalization: PermissionLocalization, localizationService: LocalizationService, textCommandLocaleProvider: TextCommandLocaleProvider, userLocaleProvider: UserLocaleProvider, ): BotCommandsMessagesFactory { - // Check if the user has a custom factory or if the fallback factory has customized files - if (defaultMessagesFactory !is FallbackDefaultMessagesFactory || hasCustomDefaultMessages()) { - logger.warn { "${classRef()} has been deprecated and will be removed in the full release." } - return BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter(defaultMessagesFactory) - } - return DefaultBotCommandsMessagesFactory( permissionLocalization, localizationService, @@ -44,18 +28,4 @@ internal open class BotCommandsMessagesFactoryAutoConfiguration internal constru userLocaleProvider ) } - - private fun hasCustomDefaultMessages(): Boolean { - // The base name is guaranteed to be "DefaultMessages" as it is hardcoded in [[DefaultMessages]] - return ClassGraph() - .acceptPathsNonRecursive("bc_localization") - .scan() - .use { scan -> - scan.allResources - .any { - val path = it.path - path.startsWith("bc_localization/DefaultMessages") && !path.startsWith("bc_localization/DefaultMessages-default") - } - } - } } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter.kt deleted file mode 100644 index e6ffb635e..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/messages/autoconfigure/BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter.kt +++ /dev/null @@ -1,27 +0,0 @@ -@file:Suppress("removal", "DEPRECATION") - -package io.github.freya022.botcommands.internal.core.messages.autoconfigure - -import io.github.freya022.botcommands.api.core.messages.BotCommandsMessages -import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory -import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.Interaction -import java.util.* - -internal class BotCommandsMessagesFactoryDefaultMessagesFactoryAdapter internal constructor( - private val defaultMessagesFactory: DefaultMessagesFactory, -) : BotCommandsMessagesFactory { - - override fun get(locale: Locale): BotCommandsMessages { - return BotCommandsMessagesDefaultMessagesAdapter(defaultMessagesFactory.get(locale)) - } - - override fun get(event: MessageReceivedEvent): BotCommandsMessages { - return BotCommandsMessagesDefaultMessagesAdapter(defaultMessagesFactory.get(event)) - } - - override fun get(event: Interaction): BotCommandsMessages { - return BotCommandsMessagesDefaultMessagesAdapter(defaultMessagesFactory.get(event)) - } -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/service/BCServiceContainerImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/service/BCServiceContainerImpl.kt index 62a431927..1f85d1110 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/service/BCServiceContainerImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/service/BCServiceContainerImpl.kt @@ -1,5 +1,3 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.internal.core.service import io.github.freya022.botcommands.api.core.config.BServiceConfig @@ -31,8 +29,7 @@ private val logger = KotlinLogging.loggerOf() internal class BCServiceContainerImpl internal constructor( internal val serviceBootstrap: BCBotCommandsBootstrap -) : BCServiceContainer, - DefaultServiceContainer { +) : BCServiceContainer { internal val serviceConfig: BServiceConfig get() = serviceBootstrap.serviceConfig internal val serviceProviders: ServiceProviders get() = serviceBootstrap.serviceProviders diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/waiter/EventWaiterImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/waiter/EventWaiterImpl.kt index 25082c93e..14887a20b 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/waiter/EventWaiterImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/waiter/EventWaiterImpl.kt @@ -130,8 +130,7 @@ internal class EventWaiterImpl(context: BContextImpl) : EventWaiter { } } - @Suppress("DEPRECATION") - private val warnedEventTypes: MutableSet> = context.config.ignoredEventIntents.toMutableSet() + private val warnedEventTypes: MutableSet> = hashSetOf() private fun checkEventIntents(eventType: Class) { val requiredIntents = GatewayIntent.fromEvents(eventType) diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/LocalizationContextImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/LocalizationContextImpl.kt index 57925413f..f691b4254 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/LocalizationContextImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/LocalizationContextImpl.kt @@ -7,7 +7,6 @@ import io.github.freya022.botcommands.api.localization.context.TextLocalizationC import io.github.freya022.botcommands.internal.utils.LocalizationUtils import io.github.freya022.botcommands.internal.utils.throwArgument import io.github.freya022.botcommands.internal.utils.throwInternal -import net.dv8tion.jda.api.interactions.DiscordLocale import java.util.* internal class LocalizationContextImpl( @@ -43,18 +42,10 @@ internal class LocalizationContextImpl( } } - @Deprecated("Use the Locale overload") - override fun withGuildLocale(guildLocale: DiscordLocale?): LocalizationContextImpl = - withGuildLocale(guildLocale?.toLocale()) - override fun withGuildLocale(guildLocale: Locale?): LocalizationContextImpl { return LocalizationContextImpl(localizationService, localizationBundle, localizationPrefix, guildLocale?.toProvider(), _userLocaleProvider) } - @Deprecated("Use the Locale overload") - override fun withUserLocale(userLocale: DiscordLocale?): LocalizationContextImpl = - withUserLocale(userLocale?.toLocale()) - override fun withUserLocale(userLocale: Locale?): LocalizationContextImpl { return LocalizationContextImpl(localizationService, localizationBundle, localizationPrefix, _guildLocaleProvider, userLocale?.toProvider()) } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/DefaultMessagesFactoryAutoConfiguration.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/DefaultMessagesFactoryAutoConfiguration.kt deleted file mode 100644 index 04292812b..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/DefaultMessagesFactoryAutoConfiguration.kt +++ /dev/null @@ -1,25 +0,0 @@ -@file:Suppress("removal", "DEPRECATION") - -package io.github.freya022.botcommands.internal.localization.autoconfigure - -import io.github.freya022.botcommands.api.core.service.annotations.ConditionalOnMissingService -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory -import io.github.freya022.botcommands.api.localization.LocalizationService -import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider -import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider -import io.github.freya022.botcommands.internal.core.service.annotations.InternalAutoConfiguration -import io.github.freya022.botcommands.internal.core.service.annotations.InternalAutoConfigurationBeanService - -@InternalAutoConfiguration -internal open class DefaultMessagesFactoryAutoConfiguration { - - @InternalAutoConfigurationBeanService - @ConditionalOnMissingService(DefaultMessagesFactory::class) - open fun defaultMessagesFactory( - localizationService: LocalizationService, - textCommandLocaleProvider: TextCommandLocaleProvider, - userLocaleProvider: UserLocaleProvider, - ): DefaultMessagesFactory { - return FallbackDefaultMessagesFactory(localizationService, textCommandLocaleProvider, userLocaleProvider) - } -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/FallbackDefaultMessagesFactory.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/FallbackDefaultMessagesFactory.kt deleted file mode 100644 index 692b911ae..000000000 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/autoconfigure/FallbackDefaultMessagesFactory.kt +++ /dev/null @@ -1,32 +0,0 @@ -@file:Suppress("removal", "DEPRECATION") - -package io.github.freya022.botcommands.internal.localization.autoconfigure - -import io.github.freya022.botcommands.api.localization.DefaultMessages -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory -import io.github.freya022.botcommands.api.localization.LocalizationService -import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider -import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider -import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.Interaction -import java.util.* - -internal class FallbackDefaultMessagesFactory internal constructor( - private val localizationService: LocalizationService, - private val textCommandLocaleProvider: TextCommandLocaleProvider, - private val userLocaleProvider: UserLocaleProvider, -): DefaultMessagesFactory { - private val cache: MutableMap = hashMapOf() - - override fun get(locale: Locale): DefaultMessages = cache.computeIfAbsent(locale) { - DefaultMessages(localizationService, it) - } - - override fun get(event: MessageReceivedEvent): DefaultMessages { - return get(textCommandLocaleProvider.getLocale(event)) - } - - override fun get(event: Interaction): DefaultMessages { - return get(userLocaleProvider.getLocale(event)) - } -} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionFactory.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionFactory.kt index 9c51765ce..6b4d4481e 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionFactory.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionFactory.kt @@ -1,11 +1,8 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.internal.localization.interaction import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory import io.github.freya022.botcommands.api.core.service.annotations.BService -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.LocalizationService import io.github.freya022.botcommands.api.localization.interaction.GuildLocaleProvider import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider @@ -18,9 +15,8 @@ internal class LocalizableInteractionFactory internal constructor( private val localizationConfig: BLocalizationConfig, private val userLocaleProvider: UserLocaleProvider, private val guildLocaleProvider: GuildLocaleProvider, - private val defaultMessagesFactory: DefaultMessagesFactory, private val messagesFactory: BotCommandsMessagesFactory, ) { internal fun create(event: IReplyCallback) = - LocalizableInteractionImpl(event, localizationService, localizationConfig, userLocaleProvider, guildLocaleProvider, defaultMessagesFactory, messagesFactory) -} \ No newline at end of file + LocalizableInteractionImpl(event, localizationService, localizationConfig, userLocaleProvider, guildLocaleProvider, messagesFactory) +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionImpl.kt index 6cc43def2..0167d6158 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/LocalizableInteractionImpl.kt @@ -1,12 +1,8 @@ -@file:Suppress("removal", "DEPRECATION") - package io.github.freya022.botcommands.internal.localization.interaction import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.core.messages.BotCommandsMessages import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory -import io.github.freya022.botcommands.api.localization.DefaultMessages -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.LocalizationService import io.github.freya022.botcommands.api.localization.context.AppLocalizationContext @@ -25,7 +21,6 @@ internal class LocalizableInteractionImpl internal constructor( localizationConfig: BLocalizationConfig, private val userLocaleProvider: UserLocaleProvider, private val guildLocaleProvider: GuildLocaleProvider, - private val defaultMessagesFactory: DefaultMessagesFactory, private val messagesFactory: BotCommandsMessagesFactory, ) : AbstractLocalizableAction(localizationConfig, localizationService), LocalizableInteraction { @@ -41,12 +36,6 @@ internal class LocalizableInteractionImpl internal constructor( .build() } - @Suppress("DEPRECATION", "removal") - @Deprecated("Replaced with getBotCommandsMessages()") - override fun getDefaultMessages(): DefaultMessages { - return defaultMessagesFactory.get(deferrableCallback) - } - override fun getBotCommandsMessages(): BotCommandsMessages { return messagesFactory.get(deferrableCallback) } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultGuildLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultGuildLocaleProvider.kt index 9f1b71384..cc6d3f6ab 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultGuildLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultGuildLocaleProvider.kt @@ -1,14 +1,10 @@ package io.github.freya022.botcommands.internal.localization.interaction.autoconfigure import io.github.freya022.botcommands.api.localization.interaction.GuildLocaleProvider -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import java.util.* internal object DefaultGuildLocaleProvider : GuildLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - override fun getDiscordLocale(interaction: Interaction): DiscordLocale = interaction.guildLocale - override fun getLocale(interaction: Interaction): Locale = interaction.guildLocale.toLocale() } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultUserLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultUserLocaleProvider.kt index df0c52566..dec44ab62 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultUserLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/interaction/autoconfigure/DefaultUserLocaleProvider.kt @@ -1,14 +1,10 @@ package io.github.freya022.botcommands.internal.localization.interaction.autoconfigure import io.github.freya022.botcommands.api.localization.interaction.UserLocaleProvider -import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.interactions.Interaction import java.util.* internal object DefaultUserLocaleProvider : UserLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - override fun getDiscordLocale(interaction: Interaction): DiscordLocale = interaction.userLocale - override fun getLocale(interaction: Interaction): Locale = interaction.userLocale.toLocale() } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandFactory.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandFactory.kt index a75a5aadd..b22ec93d6 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandFactory.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandFactory.kt @@ -1,11 +1,8 @@ -@file:Suppress("DEPRECATION") - package io.github.freya022.botcommands.internal.localization.text import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory import io.github.freya022.botcommands.api.core.service.annotations.BService -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.LocalizationService import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider import net.dv8tion.jda.api.events.message.MessageReceivedEvent @@ -16,9 +13,8 @@ internal class LocalizableTextCommandFactory internal constructor( private val localizationService: LocalizationService, private val localizationConfig: BLocalizationConfig, private val localeProvider: TextCommandLocaleProvider, - private val defaultMessagesFactory: DefaultMessagesFactory, private val messagesFactory: BotCommandsMessagesFactory, ) { internal fun create(event: MessageReceivedEvent) = - LocalizableTextCommandImpl(event, localizationService, localizationConfig, localeProvider, defaultMessagesFactory, messagesFactory) -} \ No newline at end of file + LocalizableTextCommandImpl(event, localizationService, localizationConfig, localeProvider, messagesFactory) +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandImpl.kt index ee660c419..5b9c5a000 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/LocalizableTextCommandImpl.kt @@ -1,12 +1,8 @@ -@file:Suppress("removal", "DEPRECATION") - package io.github.freya022.botcommands.internal.localization.text import io.github.freya022.botcommands.api.core.config.BLocalizationConfig import io.github.freya022.botcommands.api.core.messages.BotCommandsMessages import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory -import io.github.freya022.botcommands.api.localization.DefaultMessages -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory import io.github.freya022.botcommands.api.localization.Localization import io.github.freya022.botcommands.api.localization.LocalizationService import io.github.freya022.botcommands.api.localization.context.LocalizationContext @@ -23,7 +19,6 @@ internal class LocalizableTextCommandImpl internal constructor( localizationService: LocalizationService, localizationConfig: BLocalizationConfig, private val localeProvider: TextCommandLocaleProvider, - private val defaultMessagesFactory: DefaultMessagesFactory, private val messagesFactory: BotCommandsMessagesFactory, ) : AbstractLocalizableAction(localizationConfig, localizationService), LocalizableTextCommand { private val locale: Locale by lazy { localeProvider.getLocale(event) } @@ -35,12 +30,6 @@ internal class LocalizableTextCommandImpl internal constructor( .build() } - @Suppress("DEPRECATION", "removal") - @Deprecated("Replaced with getBotCommandsMessages()") - override fun getDefaultMessages(): DefaultMessages { - return defaultMessagesFactory.get(locale) - } - override fun getBotCommandsMessages(): BotCommandsMessages { return messagesFactory.get(locale) } diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/autoconfigure/DefaultTextCommandLocaleProvider.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/autoconfigure/DefaultTextCommandLocaleProvider.kt index 7ea2ad142..862f63038 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/autoconfigure/DefaultTextCommandLocaleProvider.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/localization/text/autoconfigure/DefaultTextCommandLocaleProvider.kt @@ -2,13 +2,9 @@ package io.github.freya022.botcommands.internal.localization.text.autoconfigure import io.github.freya022.botcommands.api.localization.text.TextCommandLocaleProvider import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.DiscordLocale import java.util.* internal object DefaultTextCommandLocaleProvider : TextCommandLocaleProvider { - @Deprecated("Use 'getLocale' instead, use 'DiscordLocale.from' / 'DiscordLocale#toLocale' if necessary") - override fun getDiscordLocale(event: MessageReceivedEvent): DiscordLocale = event.guild.locale - override fun getLocale(event: MessageReceivedEvent): Locale = event.guild.locale.toLocale() } diff --git a/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/messages/BotCommandsMessagesTests.kt b/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/messages/BotCommandsMessagesTests.kt index 812ef5b9b..08987b890 100644 --- a/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/messages/BotCommandsMessagesTests.kt +++ b/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/messages/BotCommandsMessagesTests.kt @@ -1,5 +1,3 @@ -@file:Suppress("DEPRECATION", "removal") - package io.github.freya022.botcommands.messages import dev.freya02.botcommands.helpers.AbstractIntegrationTest @@ -10,61 +8,19 @@ import io.github.freya022.botcommands.api.core.messages.DefaultBotCommandsMessag import io.github.freya022.botcommands.api.core.messages.exceptions.MissingMessageTemplateException import io.github.freya022.botcommands.api.core.service.getService import io.github.freya022.botcommands.api.core.utils.joinAsList -import io.github.freya022.botcommands.api.localization.DefaultMessages -import io.github.freya022.botcommands.api.localization.DefaultMessagesFactory -import io.github.freya022.botcommands.internal.core.messages.autoconfigure.BotCommandsMessagesFactoryAutoConfiguration import io.mockk.every import io.mockk.mockk import io.mockk.slot import io.mockk.spyk -import net.dv8tion.jda.api.events.message.MessageReceivedEvent -import net.dv8tion.jda.api.interactions.Interaction import net.dv8tion.jda.api.utils.messages.MessageCreateData import java.time.Instant import java.util.* import kotlin.reflect.KFunction import kotlin.test.Test -import kotlin.test.assertIsNot import kotlin.test.fail class BotCommandsMessagesTests : AbstractIntegrationTest() { - @Test - fun `Adapter is used when custom DefaultMessagesFactory type is used`() { - val context = createTest { - services { - registerServiceSupplier { - object : DefaultMessagesFactory { - override fun get(locale: Locale): DefaultMessages = throw UnsupportedOperationException() - override fun get(event: MessageReceivedEvent) = throw UnsupportedOperationException() - override fun get(event: Interaction) = throw UnsupportedOperationException() - } - } - } - } - - assertIsNot(context.getService()) - } - - @Test - fun `Adapter is used when custom DefaultMessages JSON exists`() { - val context = createTest { - services { - registerServiceSupplier { - mockk { - every { - botCommandsMessagesFactory(any(), any(), any(), any(), any()) - } answers { callOriginal() } - - every { this@mockk["hasCustomDefaultMessages"]() } returns true - } - } - } - } - - assertIsNot(context.getService()) - } - @Test fun `All messages have defaults`() { val context = createTest { diff --git a/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/api/core/config/JDAConfiguration.kt b/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/api/core/config/JDAConfiguration.kt index 876dde766..008f4f9a8 100644 --- a/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/api/core/config/JDAConfiguration.kt +++ b/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/api/core/config/JDAConfiguration.kt @@ -2,16 +2,10 @@ package io.github.freya022.botcommands.api.core.config import io.github.freya022.botcommands.api.core.JDAService import io.github.freya022.botcommands.internal.core.config.ConfigurationValue -import io.github.freya022.botcommands.internal.core.config.DeprecatedValue import io.github.freya022.botcommands.internal.core.config.IgnoreDefaultValue import net.dv8tion.jda.api.requests.GatewayIntent import net.dv8tion.jda.api.utils.cache.CacheFlag import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.bind.Name -import org.springframework.context.event.ContextClosedEvent -import java.time.Duration as JavaDuration -import kotlin.time.Duration -import kotlin.time.toKotlinDuration /** * Configuration properties for [JDAService]. @@ -38,36 +32,4 @@ class JDAConfiguration internal constructor( @IgnoreDefaultValue @ConfigurationValue("jda.cacheFlags") val cacheFlags: Set = emptySet(), - @Suppress("DEPRECATION") - @param:Name("devtools") - @Deprecated("For removal") - val devTools: DevTools = DevTools(), -) { - - @Deprecated("For removal") - class DevTools internal constructor( - /** - * When Spring devtools are enabled, - * enables shutting down JDA when the IoC container [closes][ContextClosedEvent]. - * - * If you disable this, you must shut down JDA manually, - * not doing so will let old instances run, receive events and cause unwanted behavior. - * - * Default: `true` - */ - @ConfigurationValue("jda.devtools.enabled", defaultValue = "true") - @Deprecated("Replaced by the built-in shutdown hook") - @DeprecatedValue("Replaced by the built-in shutdown hook", replacement = "botcommands.core.enableShutdownHook") - val enabled: Boolean = true, - shutdownTimeout: JavaDuration = JavaDuration.ofSeconds(10), - ) { - /** - * Time to wait until JDA needs to be forcefully shut down, - * in other words, this is the allowed time for a graceful shutdown. - */ - @Deprecated("For removal, shutdown is always forced") - @DeprecatedValue("For removal, shutdown is always forced") - @ConfigurationValue("jda.devtools.shutdownTimeout", type = "java.time.Duration", defaultValue = "10s") - val shutdownTimeout: Duration = shutdownTimeout.toKotlinDuration() - } -} +) diff --git a/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/internal/core/config/BotCommandsConfigurations.kt b/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/internal/core/config/BotCommandsConfigurations.kt index a96781124..d561ecd1b 100644 --- a/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/internal/core/config/BotCommandsConfigurations.kt +++ b/BotCommands-spring/src/main/kotlin/io/github/freya022/botcommands/internal/core/config/BotCommandsConfigurations.kt @@ -5,7 +5,6 @@ import io.github.freya022.botcommands.api.core.config.* import io.github.freya022.botcommands.api.core.config.application.cache.ApplicationCommandsCacheConfig import io.github.freya022.botcommands.api.core.config.application.cache.ApplicationCommandsCacheConfigBuilder import io.github.freya022.botcommands.api.utils.EmojiUtils -import net.dv8tion.jda.api.events.Event import net.dv8tion.jda.api.interactions.DiscordLocale import net.dv8tion.jda.api.requests.GatewayIntent import org.springframework.boot.context.properties.ConfigurationProperties @@ -23,8 +22,6 @@ internal class BotCommandsCoreConfiguration( override val disableExceptionsInDMs: Boolean = false, override val enableOwnerBypass: Boolean = false, override val ignoredIntents: Set = emptySet(), - @Deprecated("Replaced by EventWaiterBuilder.ignoreMissingIntents()") - override val ignoredEventIntents: Set> = emptySet(), override val ignoreRestRateLimiter: Boolean = false, override val enableShutdownHook: Boolean = true, ) : BConfigProps { @@ -38,8 +35,6 @@ internal fun BConfigBuilder.applyConfig(configuration: BotCommandsCoreConfigurat disableExceptionsInDMs = configuration.disableExceptionsInDMs enableOwnerBypass = configuration.enableOwnerBypass ignoredIntents += configuration.ignoredIntents - @Suppress("DEPRECATION") - ignoredEventIntents += configuration.ignoredEventIntents ignoreRestRateLimiter = configuration.ignoreRestRateLimiter } From 9929eff04dfcb627828dec2c8e2bbd3f00c72f9c Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:44:10 +0100 Subject: [PATCH 2/7] jda-ktx: Remove deprecated migration helpers --- BotCommands-jda-ktx/build.gradle.kts | 6 - .../freya02/botcommands/jda/ktx/Channels.kt | 3 - .../botcommands/jda/ktx/DeprecatedInBcCore.kt | 4 - .../dev/freya02/botcommands/jda/ktx/Files.kt | 1 - .../freya02/botcommands/jda/ktx/Mentions.kt | 1 - .../botcommands/jda/ktx/ReplaceJdaKtx.kt | 4 - .../jda/ktx/components/ActionRow.kt | 6 - .../jda/ktx/components/IDisableable.kt | 7 - .../jda/ktx/components/SelectMenus.kt | 3 - .../jda/ktx/coroutines/Coroutines.kt | 4 - .../jda/ktx/durations/Durations.kt | 16 -- .../jda/ktx/messages/ContentIntent.kt | 2 - .../jda/ktx/messages/Converters.kt | 3 - .../botcommands/jda/ktx/messages/Deletes.kt | 4 - .../botcommands/jda/ktx/messages/Editing.kt | 5 - .../botcommands/jda/ktx/messages/EditingTo.kt | 4 - .../botcommands/jda/ktx/messages/Messages.kt | 11 - .../jda/ktx/messages/ReplacingWith.kt | 4 - .../botcommands/jda/ktx/messages/Sending.kt | 5 - .../botcommands/jda/ktx/messages/SendingTo.kt | 4 - .../botcommands/jda/ktx/ranges/Ranges.kt | 2 - .../jda/ktx/requests/ErrorResponses.kt | 4 - .../jda/ktx/requests/RestAction.kt | 6 - .../jda/ktx/requests/RestResult.kt | 15 -- .../botcommands/jda/ktx/retrieve/Guild.kt | 8 - .../retrieve/InvalidChannelTypeException.kt | 3 - .../botcommands/jda/ktx/retrieve/JDA.kt | 8 - .../jda/ktx/MigrationSnapshotTest.kt | 37 --- .../src/test/resources/ksp_snapshot.zip | Bin 16321 -> 0 bytes .../build.gradle.kts | 23 -- .../jda/ktx/deprecation/utils/KaAccessor.java | 14 -- .../jda/ktx/deprecation/CompatSourceFile.kt | 10 - .../jda/ktx/deprecation/FindReplacePairs.kt | 24 -- .../jda/ktx/deprecation/RewriteFindReplace.kt | 19 -- .../aggregate/AggregateMigrationProcessor.kt | 41 ---- .../AggregateMigrationProcessorProvider.kt | 14 -- .../processor/bc/DeprecationProcessor.kt | 211 ------------------ .../bc/DeprecationProcessorProvider.kt | 14 -- .../processor/ktx/JdaKtxClassProcessor.kt | 26 --- .../processor/ktx/JdaKtxFunctionProcessor.kt | 40 ---- .../processor/ktx/JdaKtxMigrationProcessor.kt | 111 --------- .../ktx/JdaKtxMigrationProcessorProvider.kt | 15 -- .../jda/ktx/deprecation/render/KtRenderers.kt | 104 --------- .../jda/ktx/deprecation/utils/Collections.kt | 9 - .../jda/ktx/deprecation/utils/Recipe.kt | 31 --- .../utils/RichKotlinClassMetadata.kt | 8 - .../jda/ktx/deprecation/utils/Strings.kt | 8 - ...ols.ksp.processing.SymbolProcessorProvider | 3 - settings.gradle.kts | 1 - 49 files changed, 906 deletions(-) delete mode 100644 BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/DeprecatedInBcCore.kt delete mode 100644 BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ReplaceJdaKtx.kt delete mode 100644 BotCommands-jda-ktx/src/test/kotlin/dev/freya02/botcommands/jda/ktx/MigrationSnapshotTest.kt delete mode 100644 BotCommands-jda-ktx/src/test/resources/ksp_snapshot.zip delete mode 100644 jda-ktx-deprecation-processor/build.gradle.kts delete mode 100644 jda-ktx-deprecation-processor/src/main/java/dev/freya02/botcommands/jda/ktx/deprecation/utils/KaAccessor.java delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/CompatSourceFile.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/FindReplacePairs.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/RewriteFindReplace.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessor.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessorProvider.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessor.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessorProvider.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxClassProcessor.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxFunctionProcessor.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessor.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessorProvider.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/render/KtRenderers.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Collections.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Recipe.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/RichKotlinClassMetadata.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Strings.kt delete mode 100644 jda-ktx-deprecation-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider diff --git a/BotCommands-jda-ktx/build.gradle.kts b/BotCommands-jda-ktx/build.gradle.kts index b943cc508..4746cd3f4 100644 --- a/BotCommands-jda-ktx/build.gradle.kts +++ b/BotCommands-jda-ktx/build.gradle.kts @@ -5,8 +5,6 @@ plugins { id("kotlin-conventions") id("publish-conventions") id("dokka-conventions") - - alias(libs.plugins.ksp) } dependencies { @@ -15,8 +13,6 @@ dependencies { compileOnly(libs.jda) api(libs.kotlinx.coroutines.core) - ksp(projects.jdaKtxDeprecationProcessor) - // -------------------- TEST DEPENDENCIES -------------------- testImplementation(libs.bundles.test) @@ -29,8 +25,6 @@ dependencies { tasks.named("test") { useJUnitPlatform() - - environment("KSP_OUTPUT", layout.buildDirectory.dir("generated/ksp").get().asFile.path) } publishedProjectEnvironment { diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Channels.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Channels.kt index 3387bf4b3..2174ce73c 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Channels.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Channels.kt @@ -6,17 +6,14 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel /** * Same as [IGuildChannelContainer.getChannelById] but with a reified type parameter. */ -@ReplaceJdaKtx inline fun IGuildChannelContainer.getChannel(id: Long): T? = getChannelById(T::class.java, id) /** * Same as [IGuildChannelContainer.getChannelById] but with a reified type parameter. */ -@ReplaceJdaKtx inline fun IGuildChannelContainer.getChannel(id: String): T? = getChannelById(T::class.java, id) /** * Same as [IGuildChannelContainer.getChannelById] but with a reified type parameter. */ -@ReplaceJdaKtx inline fun IGuildChannelContainer.getChannel(id: ULong): T? = getChannel(id.toLong()) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/DeprecatedInBcCore.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/DeprecatedInBcCore.kt deleted file mode 100644 index a816388b9..000000000 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/DeprecatedInBcCore.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.freya02.botcommands.jda.ktx - -@Retention(AnnotationRetention.SOURCE) -internal annotation class DeprecatedInBcCore diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Files.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Files.kt index 78c3b0998..d1f26d05a 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Files.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Files.kt @@ -2,5 +2,4 @@ package dev.freya02.botcommands.jda.ktx import net.dv8tion.jda.api.utils.FileUpload -@ReplaceJdaKtx("dev.minn.jda.ktx.messages") fun FileUpload.into() = listOf(this) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Mentions.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Mentions.kt index eea603d9f..c527ead0f 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Mentions.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/Mentions.kt @@ -7,7 +7,6 @@ import org.apache.commons.collections4.Bag /** * Same as [Mentions.getChannels] but with a reified type parameter. */ -@ReplaceJdaKtx @Suppress("EXTENSION_SHADOWED_BY_MEMBER") inline fun Mentions.getChannels(): List { return getChannels(T::class.java) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ReplaceJdaKtx.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ReplaceJdaKtx.kt deleted file mode 100644 index e7eb8df8f..000000000 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ReplaceJdaKtx.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.freya02.botcommands.jda.ktx - -@Retention(AnnotationRetention.SOURCE) -internal annotation class ReplaceJdaKtx(val pkg: String = "") diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/ActionRow.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/ActionRow.kt index 944a9e952..931aa9770 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/ActionRow.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/ActionRow.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.components -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import net.dv8tion.jda.api.components.actionrow.ActionRow import net.dv8tion.jda.api.components.actionrow.ActionRowChildComponent import net.dv8tion.jda.api.components.buttons.Button @@ -50,21 +49,16 @@ inline fun ActionRow(uniqueId: Int = -1, block: InlineActionRow.() -> Unit): Act /** * Construct an [ActionRow] from the provided components */ -@ReplaceJdaKtx fun row(component: ActionRowChildComponent, vararg components: ActionRowChildComponent) = ActionRow.of(component, *components) /** * Construct an [ActionRow] from the provided components */ -@ReplaceJdaKtx fun Collection.row() = ActionRow.of(this) -@ReplaceJdaKtx("dev.minn.jda.ktx.messages") @JvmName("intoComponents") fun Collection.into(): List = listOf(this.row()) -@ReplaceJdaKtx("dev.minn.jda.ktx.messages") fun ActionRowChildComponent.into(): List = row(this).into() -@ReplaceJdaKtx("dev.minn.jda.ktx.messages") fun T.into(): List = listOf(this) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/IDisableable.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/IDisableable.kt index 08ad09e61..49cb8d6b5 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/IDisableable.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/IDisableable.kt @@ -1,13 +1,11 @@ package dev.freya02.botcommands.jda.ktx.components -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import net.dv8tion.jda.api.components.Component import net.dv8tion.jda.api.components.tree.ComponentTree /** * Returns a list containing the results of disabling/enabling each component in the original collection. */ -@ReplaceJdaKtx @Suppress("UNCHECKED_CAST") fun Iterable.withDisabled(disabled: Boolean): List = ComponentTree.of(this.toList()).withDisabled(disabled).components as List @@ -15,13 +13,11 @@ fun Iterable.withDisabled(disabled: Boolean): List = /** * Returns a list containing the results of disabling each component in the original collection. */ -@ReplaceJdaKtx fun Iterable.asDisabled() = withDisabled(true) /** * Returns a list containing the results of enabling each component in the original collection. */ -@ReplaceJdaKtx fun Iterable.asEnabled() = withDisabled(false) /** @@ -29,7 +25,6 @@ fun Iterable.asEnabled() = withDisabled(false) * * The operation is _intermediate_ and _stateless_. */ -@ReplaceJdaKtx fun Sequence.withDisabled(disabled: Boolean) = asIterable().withDisabled(disabled).asSequence() @@ -38,7 +33,6 @@ fun Sequence.withDisabled(disabled: Boolean) = * * The operation is _intermediate_ and _stateless_. */ -@ReplaceJdaKtx fun Sequence.asDisabled() = withDisabled(true) /** @@ -46,5 +40,4 @@ fun Sequence.asDisabled() = withDisabled(true) * * The operation is _intermediate_ and _stateless_. */ -@ReplaceJdaKtx fun Sequence.asEnabled() = withDisabled(false) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/SelectMenus.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/SelectMenus.kt index e50705197..8b4211617 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/SelectMenus.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/components/SelectMenus.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.components -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import net.dv8tion.jda.api.components.selections.SelectOption import net.dv8tion.jda.api.components.selections.StringSelectMenu import net.dv8tion.jda.api.entities.emoji.Emoji @@ -14,7 +13,6 @@ import net.dv8tion.jda.api.entities.emoji.Emoji * @param emoji The emoji of this option * @param default Whether this option is selected by default */ -@ReplaceJdaKtx fun SelectOption( label: String, value: String, @@ -35,7 +33,6 @@ fun SelectOption( * @param emoji The emoji of this option * @param default Whether this option is selected by default */ -@ReplaceJdaKtx("dev.minn.jda.ktx.interactions.components") fun StringSelectMenu.Builder.option( label: String, value: String, diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/coroutines/Coroutines.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/coroutines/Coroutines.kt index f02526870..d69ddd48b 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/coroutines/Coroutines.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/coroutines/Coroutines.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.coroutines -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.future.await @@ -14,13 +13,11 @@ import kotlin.coroutines.resumeWithException /** * Suspends until the REST request is finished and returns the result. */ -@ReplaceJdaKtx("dev.minn.jda.ktx.coroutines") suspend fun RestAction.await(): T = submit(true).await() /** * Suspends until the gateway request is finished and returns the result. */ -@ReplaceJdaKtx("dev.minn.jda.ktx.coroutines") suspend fun Task.await(): T = suspendCancellableCoroutine { cont -> cont.invokeOnCancellation { cancel() } onSuccess { r -> cont.resume(r) } @@ -30,7 +27,6 @@ suspend fun Task.await(): T = suspendCancellableCoroutine { cont -> /** * Converts the pagination action to a [Flow]. */ -@ReplaceJdaKtx fun PaginationAction.asFlow(): Flow = flow { cache(false) var elements: List = await() diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/durations/Durations.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/durations/Durations.kt index cbb9d061a..67ee8aa7e 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/durations/Durations.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/durations/Durations.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.durations -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.entities.BulkBanResponse import net.dv8tion.jda.api.entities.Guild @@ -25,21 +24,18 @@ import kotlin.time.toJavaDuration /** * @see RestAction.delay */ -@DeprecatedInBcCore fun RestAction.delay(duration: Duration): RestAction = delay(duration.toJavaDuration()) /** * @see RestAction.delay */ -@DeprecatedInBcCore fun RestAction.delay(duration: Duration, scheduler: ScheduledExecutorService): RestAction = delay(duration.toJavaDuration(), scheduler) /** * @see RestAction.timeout */ -@DeprecatedInBcCore @Suppress("UNCHECKED_CAST") fun > T.timeout(duration: Duration): T = timeout(duration.inWholeMilliseconds, TimeUnit.MILLISECONDS) as T @@ -47,72 +43,60 @@ fun > T.timeout(duration: Duration): T = /** * @see JDA.awaitShutdown */ -@DeprecatedInBcCore fun JDA.awaitShutdown(timeout: Duration): Boolean = awaitShutdown(timeout.toJavaDuration()) /** * @see Guild.timeoutFor */ -@DeprecatedInBcCore fun Guild.timeoutFor(user: UserSnowflake, duration: Duration): AuditableRestAction = timeoutFor(user, duration.toJavaDuration()) /** * @see Member.timeoutFor */ -@DeprecatedInBcCore fun Member.timeoutFor(duration: Duration): AuditableRestAction = timeoutFor(duration.toJavaDuration()) /** * @see Member.ban */ -@DeprecatedInBcCore fun Member.ban(deletionTimeframe: Duration): AuditableRestAction = ban(deletionTimeframe.inWholeSeconds.toInt(), TimeUnit.SECONDS) /** * @see Guild.ban */ -@DeprecatedInBcCore fun Guild.ban(user: UserSnowflake, deletionTimeframe: Duration): AuditableRestAction = ban(user, deletionTimeframe.inWholeSeconds.toInt(), TimeUnit.SECONDS) /** * See [bulk ban from JDA](https://docs.jda.wiki/net/dv8tion/jda/api/entities/Guild.html#ban(java.util.Collection,java.time.Duration)) */ -@DeprecatedInBcCore fun Guild.ban(users: Collection, duration: Duration): AuditableRestAction = ban(users, duration.toJavaDuration()) /** * @see TimeFormat.after */ -@DeprecatedInBcCore fun TimeFormat.after(duration: Duration): Timestamp = after(duration.toJavaDuration()) /** * @see TimeFormat.before */ -@DeprecatedInBcCore fun TimeFormat.before(duration: Duration): Timestamp = before(duration.toJavaDuration()) /** * @see Timestamp.plus */ -@DeprecatedInBcCore operator fun Timestamp.plus(duration: Duration): Timestamp = plus(duration.toJavaDuration()) /** * @see Timestamp.minus */ -@DeprecatedInBcCore operator fun Timestamp.minus(duration: Duration): Timestamp = minus(duration.toJavaDuration()) /** * @see Task.setTimeout */ -@DeprecatedInBcCore fun Task.setTimeout(duration: Duration): Task = setTimeout(duration.toJavaDuration()) /** * @see GatewayTask.setTimeout */ -@DeprecatedInBcCore fun GatewayTask.setTimeout(duration: Duration): Task = setTimeout(duration.toJavaDuration()) /** diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ContentIntent.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ContentIntent.kt index 15eba33c7..b82d78044 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ContentIntent.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ContentIntent.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.internal.entities.ReceivedMessage /** @@ -8,7 +7,6 @@ import net.dv8tion.jda.internal.entities.ReceivedMessage * * **Note:** This applies to all threads while the current code is inside this function */ -@DeprecatedInBcCore inline fun suppressContentWarning(block: () -> R): R { val oldFlag = ReceivedMessage.didContentIntentWarning ReceivedMessage.didContentIntentWarning = true diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Converters.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Converters.kt index 79714a8b3..795b975b0 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Converters.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Converters.kt @@ -1,19 +1,16 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.utils.messages.MessageCreateData import net.dv8tion.jda.api.utils.messages.MessageEditData /** * @see MessageEditData.fromCreateData */ -@DeprecatedInBcCore fun MessageCreateData.toEditData(): MessageEditData = MessageEditData.fromCreateData(this) /** * @see MessageCreateData.fromEditData */ -@DeprecatedInBcCore fun MessageEditData.toCreateData(): MessageCreateData = MessageCreateData.fromEditData(this) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Deletes.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Deletes.kt index 3c8080e8d..48463ab82 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Deletes.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Deletes.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import dev.freya02.botcommands.jda.ktx.durations.delay import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.interactions.InteractionHook @@ -12,7 +11,6 @@ import kotlin.time.Duration * * **Note:** This delays the rest action by the given delay. */ -@DeprecatedInBcCore fun RestAction.deleteDelayed(hook: InteractionHook, delay: Duration?): RestAction { return withFiniteDelayOrSelf(delay) { finiteDelay -> delay(finiteDelay).flatMapOriginal { hook.deleteOriginal() } @@ -24,7 +22,6 @@ fun RestAction.deleteDelayed(hook: InteractionHook, delay: Duration?): Re * * **Note:** This delays the rest action by the given delay. */ -@DeprecatedInBcCore fun RestAction.deleteDelayed(delay: Duration?): RestAction { return withFiniteDelayOrSelf(delay) { finiteDelay -> delay(finiteDelay).flatMapOriginal(InteractionHook::deleteOriginal) @@ -36,7 +33,6 @@ fun RestAction.deleteDelayed(delay: Duration?): RestAction.deleteDelayed(delay: Duration?): RestAction { return withFiniteDelayOrSelf(delay) { finiteDelay -> diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Editing.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Editing.kt index 5a9ee2707..6c79917e6 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Editing.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Editing.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import net.dv8tion.jda.api.components.MessageTopLevelComponent import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.MessageEmbed @@ -25,7 +24,6 @@ import net.dv8tion.jda.api.utils.messages.MessageRequest * * @see IMessageEditCallback.editMessage */ -@ReplaceJdaKtx @Suppress("FunctionName") // To facilitate imports inline fun IMessageEditCallback.editMessage_( content: String? = null, @@ -50,7 +48,6 @@ inline fun IMessageEditCallback.editMessage_( * * @see InteractionHook.editMessageById */ -@ReplaceJdaKtx inline fun InteractionHook.editMessage( id: String = "@original", content: String? = null, @@ -75,7 +72,6 @@ inline fun InteractionHook.editMessage( * * @see MessageChannel.editMessageById */ -@ReplaceJdaKtx inline fun MessageChannel.editMessage( id: String, content: String? = null, @@ -99,7 +95,6 @@ inline fun MessageChannel.editMessage( * * @see Message.editMessage */ -@ReplaceJdaKtx inline fun Message.edit( content: String? = null, embeds: Collection? = null, diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/EditingTo.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/EditingTo.kt index 6922e6596..7fa3b1b28 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/EditingTo.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/EditingTo.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel import net.dv8tion.jda.api.interactions.InteractionHook @@ -13,20 +12,17 @@ import net.dv8tion.jda.api.utils.messages.MessageEditData /** * @see IMessageEditCallback.editMessage */ -@DeprecatedInBcCore fun MessageEditData.edit(callback: IMessageEditCallback): MessageEditCallbackAction = callback.editMessage(this) /** * @see InteractionHook.editOriginal */ -@DeprecatedInBcCore fun MessageEditData.edit(hook: InteractionHook): WebhookMessageEditAction = hook.editOriginal(this) /** * @see MessageChannel.editMessageById */ -@DeprecatedInBcCore fun MessageEditData.edit(channel: MessageChannel, id: Long): MessageEditAction = channel.editMessageById(id, this) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Messages.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Messages.kt index 921568b0f..bd118f2b7 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Messages.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Messages.kt @@ -2,7 +2,6 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import dev.freya02.botcommands.jda.ktx.components.* import dev.freya02.botcommands.jda.ktx.hex import dev.freya02.botcommands.jda.ktx.hsb @@ -42,7 +41,6 @@ typealias InlineMessageEdit = InlineMessage @PublishedApi internal val NO_CONTENT = emptyList() -@ReplaceJdaKtx inline fun MessageCreateBuilder( content: String? = null, embeds: Collection = NO_CONTENT, @@ -69,7 +67,6 @@ inline fun MessageCreateBuilder( InlineMessage(this).apply(builder) } -@ReplaceJdaKtx inline fun MessageCreate( content: String? = null, embeds: Collection = NO_CONTENT, @@ -103,7 +100,6 @@ inline fun MessageCreate( * @param replace `true` to replace the entire message, `false` to only replace specified parts * @param builder Additional configuration, can override the previously provided parameters */ -@ReplaceJdaKtx inline fun MessageEditBuilder( content: String? = null, embeds: Collection? = null, @@ -135,7 +131,6 @@ inline fun MessageEditBuilder( * @param replace `true` to replace the entire message, `false` to only replace specified parts * @param builder Additional configuration, can override the previously provided parameters */ -@ReplaceJdaKtx inline fun MessageEdit( content: String? = null, embeds: Collection? = null, @@ -156,7 +151,6 @@ inline fun MessageEdit( builder ).build() -@ReplaceJdaKtx inline fun Embed( color: Int? = null, timestamp: TemporalAccessor? = null, @@ -165,7 +159,6 @@ inline fun Embed( return EmbedBuilder(color, timestamp, builder).build() } -@ReplaceJdaKtx inline fun EmbedBuilder( color: Int? = null, timestamp: TemporalAccessor? = null, @@ -178,7 +171,6 @@ inline fun EmbedBuilder( InlineEmbed(this).apply(builder) } -@ReplaceJdaKtx @MessageBuilderDSL class InlineMessage(val builder: AbstractMessageBuilder) { @@ -513,7 +505,6 @@ class InlineMessage(val builder: AbstractMessageBuilder) { } } -@ReplaceJdaKtx @MessageBuilderDSL class InlineEmbed(val builder: EmbedBuilder) { @@ -643,7 +634,6 @@ class Accumulator internal constructor() { } } -@ReplaceJdaKtx sealed interface MentionConfig { val type: MentionType @@ -688,7 +678,6 @@ class WhitelistMentionConfig( } } -@ReplaceJdaKtx data class Mentions( var users: MentionConfig, var roles: MentionConfig, diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ReplacingWith.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ReplacingWith.kt index f0c240fb3..df67bdd63 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ReplacingWith.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/ReplacingWith.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.interactions.InteractionHook import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction @@ -10,20 +9,17 @@ import net.dv8tion.jda.api.utils.messages.MessageEditData /** * @see InteractionHook.editOriginal */ -@DeprecatedInBcCore fun InteractionHook.replaceWith(data: MessageEditData): WebhookMessageEditAction = editOriginal(data).setReplace(true) /** * @see InteractionHook.editOriginal */ -@DeprecatedInBcCore fun InteractionHook.replaceWith(data: MessageCreateData): WebhookMessageEditAction = editOriginal(data.toEditData()).setReplace(true) /** * @see InteractionHook.editOriginal */ -@DeprecatedInBcCore fun InteractionHook.replaceWith(content: String): WebhookMessageEditAction = editOriginal(content).setReplace(true) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Sending.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Sending.kt index ef451b3ed..240d67e72 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Sending.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/Sending.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx import net.dv8tion.jda.api.components.MessageTopLevelComponent import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.MessageEmbed @@ -16,7 +15,6 @@ import net.dv8tion.jda.api.utils.messages.MessageRequest /** * @see IReplyCallback.reply */ -@ReplaceJdaKtx inline fun IReplyCallback.reply_( content: String? = null, embeds: Collection = NO_CONTENT, @@ -32,7 +30,6 @@ inline fun IReplyCallback.reply_( /** * @see InteractionHook.sendMessage */ -@ReplaceJdaKtx inline fun InteractionHook.send( content: String? = null, embeds: Collection = NO_CONTENT, @@ -48,7 +45,6 @@ inline fun InteractionHook.send( /** * @see MessageChannel.sendMessage */ -@ReplaceJdaKtx inline fun MessageChannel.send( content: String? = null, embeds: Collection = NO_CONTENT, @@ -64,7 +60,6 @@ inline fun MessageChannel.send( * @see MessageChannel.sendMessage * @see MessageCreateAction.setMessageReference */ -@ReplaceJdaKtx inline fun Message.reply_( content: String? = null, embeds: Collection = NO_CONTENT, diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/SendingTo.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/SendingTo.kt index c22589e37..1da202479 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/SendingTo.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/messages/SendingTo.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.messages -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel import net.dv8tion.jda.api.interactions.InteractionHook @@ -13,20 +12,17 @@ import net.dv8tion.jda.api.utils.messages.MessageCreateData /** * @see IReplyCallback.reply */ -@DeprecatedInBcCore fun MessageCreateData.send(callback: IReplyCallback, ephemeral: Boolean = false): ReplyCallbackAction = callback.reply(this).setEphemeral(ephemeral) /** * @see InteractionHook.sendMessage */ -@DeprecatedInBcCore fun MessageCreateData.send(hook: InteractionHook, ephemeral: Boolean = false): WebhookMessageCreateAction = hook.sendMessage(this).setEphemeral(ephemeral) /** * @see MessageChannel.sendMessage */ -@DeprecatedInBcCore fun MessageCreateData.send(channel: MessageChannel): MessageCreateAction = channel.sendMessage(this) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ranges/Ranges.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ranges/Ranges.kt index 5f443b141..7b0ed7fa3 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ranges/Ranges.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/ranges/Ranges.kt @@ -1,10 +1,8 @@ package dev.freya02.botcommands.jda.ktx.ranges -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.components.selections.SelectMenu /** * The minimum and maximum amount of values a user can select, must not exceed [SelectMenu.OPTIONS_MAX_AMOUNT]. */ -@DeprecatedInBcCore fun > SelectMenu.Builder<*, B>.setRequiredRange(range: IntRange): B = setRequiredRange(range.first, range.last) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/ErrorResponses.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/ErrorResponses.kt index 85aabd515..17e0f32bc 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/ErrorResponses.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/ErrorResponses.kt @@ -2,7 +2,6 @@ package dev.freya02.botcommands.jda.ktx.requests -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.exceptions.ErrorResponseException import net.dv8tion.jda.api.requests.ErrorResponse import kotlin.contracts.ExperimentalContracts @@ -16,7 +15,6 @@ import kotlin.contracts.contract * @see runIgnoringResponse * @see runIgnoringResponseOrNull */ -@DeprecatedInBcCore inline fun runCatchingResponse(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> R): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -34,7 +32,6 @@ inline fun runCatchingResponse(ignored: ErrorResponse, vararg ignoredRespons * @see ignore * @see runIgnoringResponseOrNull */ -@DeprecatedInBcCore inline fun runIgnoringResponse(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> Unit) { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -59,7 +56,6 @@ inline fun runIgnoringResponse(ignored: ErrorResponse, vararg ignoredResponses: * @see runIgnoringResponse * @see awaitOrNullOn */ -@DeprecatedInBcCore inline fun runIgnoringResponseOrNull(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> R): R? { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestAction.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestAction.kt index c58c0f6e7..b788656ea 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestAction.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestAction.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.requests -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import dev.freya02.botcommands.jda.ktx.coroutines.await import net.dv8tion.jda.api.exceptions.ErrorHandler import net.dv8tion.jda.api.requests.ErrorResponse @@ -9,7 +8,6 @@ import net.dv8tion.jda.api.requests.RestAction /** * Awaits the completion of this RestAction. */ -@DeprecatedInBcCore suspend fun RestAction<*>.awaitUnit() { await() } @@ -17,7 +15,6 @@ suspend fun RestAction<*>.awaitUnit() { /** * Awaits the completion of this RestAction and returns `null`. */ -@DeprecatedInBcCore suspend fun RestAction<*>.awaitNull(): R? { await() return null @@ -30,7 +27,6 @@ suspend fun RestAction<*>.awaitNull(): R? { * * @see ErrorHandler */ -@DeprecatedInBcCore fun RestAction<*>.queueIgnoring(ignored: ErrorResponse, vararg errorResponses: ErrorResponse) { queue(null, ErrorHandler().ignore(ignored, *errorResponses)) } @@ -43,7 +39,6 @@ fun RestAction<*>.queueIgnoring(ignored: ErrorResponse, vararg errorResponses: E * * @see runIgnoringResponseOrNull */ -@DeprecatedInBcCore suspend fun RestAction.awaitOrNullOn(ignored: ErrorResponse, vararg errorResponses: ErrorResponse): R? { return runIgnoringResponseOrNull(ignored, *errorResponses) { await() @@ -53,7 +48,6 @@ suspend fun RestAction.awaitOrNullOn(ignored: ErrorResponse, vararg error /** * Awaits the completion of this RestAction and wraps it in a Result. */ -@DeprecatedInBcCore suspend fun RestAction.awaitCatching(): RestResult { return runCatchingRest { await() } } diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestResult.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestResult.kt index 2ee791aa6..877d4bddf 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestResult.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/requests/RestResult.kt @@ -2,7 +2,6 @@ package dev.freya02.botcommands.jda.ktx.requests -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import net.dv8tion.jda.api.exceptions.ErrorResponseException import net.dv8tion.jda.api.requests.ErrorResponse import kotlin.contracts.ExperimentalContracts @@ -21,7 +20,6 @@ import kotlin.reflect.KClass */ @JvmInline @Suppress("UNCHECKED_CAST") -@DeprecatedInBcCore value class RestResult @PublishedApi internal constructor( @PublishedApi internal val value: Any? ) { @@ -175,7 +173,6 @@ value class RestResult @PublishedApi internal constructor( * * Returns the original `RestResult` unchanged. */ -@DeprecatedInBcCore inline fun RestResult.onErrorResponseException(block: (ErrorResponseException) -> Unit): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -194,7 +191,6 @@ inline fun RestResult.onErrorResponseException(block: (ErrorResponseExcep * @see ignore * @see handle */ -@DeprecatedInBcCore inline fun RestResult.onErrorResponse(block: (ErrorResponse) -> Unit): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -213,7 +209,6 @@ inline fun RestResult.onErrorResponse(block: (ErrorResponse) -> Unit): Re * @see ignore * @see handle */ -@DeprecatedInBcCore inline fun RestResult.onErrorResponse(error: ErrorResponse, block: (ErrorResponseException) -> Unit): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -232,7 +227,6 @@ inline fun RestResult.onErrorResponse(error: ErrorResponse, block: (Error * * @see handle */ -@DeprecatedInBcCore inline fun RestResult.ignore(predicate: (Throwable) -> Boolean): RestResult { contract { callsInPlace(predicate, InvocationKind.AT_MOST_ONCE) @@ -259,7 +253,6 @@ inline fun RestResult.ignore(predicate: (Throwable) -> Boolean): RestResu * * @see handle */ -@DeprecatedInBcCore fun RestResult.ignore(ignored: ErrorResponse, vararg responses: ErrorResponse): RestResult = ignore { it is ErrorResponseException && (it.errorResponse == ignored || it.errorResponse in responses) } @@ -272,7 +265,6 @@ fun RestResult.ignore(ignored: ErrorResponse, vararg responses: ErrorResp * * @see handle */ -@DeprecatedInBcCore fun RestResult.ignore(ignored: KClass, vararg types: KClass): RestResult = ignore { throwable -> ignored.isInstance(throwable) || types.any { it.isInstance(throwable) } } @@ -284,7 +276,6 @@ fun RestResult.ignore(ignored: KClass, vararg types: KClas * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.recover(predicate: (Throwable) -> Boolean, block: (Throwable) -> R): RestResult { contract { callsInPlace(predicate, InvocationKind.AT_MOST_ONCE) @@ -309,7 +300,6 @@ inline fun RestResult.recover(predicate: (Throwable) -> Boolean, b * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.recover(response: ErrorResponse, vararg responses: ErrorResponse, block: (ErrorResponseException) -> R): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -329,7 +319,6 @@ inline fun RestResult.recover(response: ErrorResponse, vararg resp * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.recover(type: KClass, vararg types: KClass, block: (Throwable) -> R): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -351,7 +340,6 @@ inline fun RestResult.recover(type: KClass, vararg * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.handle(predicate: (Throwable) -> Boolean, block: (Throwable) -> Unit): RestResult { contract { callsInPlace(predicate, InvocationKind.UNKNOWN) @@ -379,7 +367,6 @@ inline fun RestResult.handle(predicate: (Throwable) -> Boolean, block: (T * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.handle(type: ErrorResponse, vararg responses: ErrorResponse, block: (ErrorResponseException) -> Unit): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -401,7 +388,6 @@ inline fun RestResult.handle(type: ErrorResponse, vararg responses: Error * * @see ignore */ -@DeprecatedInBcCore inline fun RestResult.handle(type: KClass, vararg types: KClass, block: (Throwable) -> Unit): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -418,7 +404,6 @@ inline fun RestResult.handle(type: KClass, vararg types: K * catching any [Throwable] exception that was thrown from the [block] function execution * and encapsulating it as a failure. */ -@DeprecatedInBcCore inline fun runCatchingRest(block: () -> T): RestResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt index e0b3c6ee4..f3679c403 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.retrieve -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import dev.freya02.botcommands.jda.ktx.IgnoreForMatch import dev.freya02.botcommands.jda.ktx.coroutines.await import dev.freya02.botcommands.jda.ktx.deferredRestAction @@ -37,7 +36,6 @@ import net.dv8tion.jda.internal.requests.RestActionImpl * * @see Guild.retrieveMemberById */ -@DeprecatedInBcCore suspend fun Guild.retrieveMemberByIdOrNull(userId: String, @IgnoreForMatch useCache: Boolean = true): Member? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_MEMBER, ErrorResponse.UNKNOWN_USER) { retrieveMemberById(userId).useCache(useCache).await() @@ -55,7 +53,6 @@ suspend fun Guild.retrieveMemberByIdOrNull(userId: String, @IgnoreForMatch useCa * * @see Guild.retrieveMemberById */ -@DeprecatedInBcCore suspend fun Guild.retrieveMemberByIdOrNull(userId: Long, @IgnoreForMatch useCache: Boolean = true): Member? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_MEMBER, ErrorResponse.UNKNOWN_USER) { retrieveMemberById(userId).useCache(useCache).await() @@ -73,7 +70,6 @@ suspend fun Guild.retrieveMemberByIdOrNull(userId: Long, @IgnoreForMatch useCach * * @see Guild.retrieveMember */ -@DeprecatedInBcCore suspend fun Guild.retrieveMemberOrNull(user: UserSnowflake, @IgnoreForMatch useCache: Boolean = true): Member? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_MEMBER, ErrorResponse.UNKNOWN_USER) { retrieveMember(user).useCache(useCache).await() @@ -87,7 +83,6 @@ suspend fun Guild.retrieveMemberOrNull(user: UserSnowflake, @IgnoreForMatch useC * * @see Guild.retrieveBan */ -@DeprecatedInBcCore suspend fun Guild.retrieveBanOrNull(user: UserSnowflake): Ban? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_BAN) { retrieveBan(user).await() @@ -102,7 +97,6 @@ suspend fun Guild.retrieveBanOrNull(user: UserSnowflake): Ban? { * * @see Guild.retrieveVanityInvite */ -@DeprecatedInBcCore suspend fun Guild.retrieveVanityInviteOrNull(): VanityInvite? { if (vanityCode == null) return null @@ -120,7 +114,6 @@ suspend fun Guild.retrieveVanityInviteOrNull(): VanityInvite? { * * @see retrieveThreadChannelOrNull */ -@DeprecatedInBcCore fun Guild.retrieveThreadChannelById(id: Long): CacheRestAction { return jda.deferredRestAction( valueSupplier = { getThreadChannelById(id) }, @@ -162,7 +155,6 @@ fun Guild.retrieveThreadChannelById(id: String): CacheRestAction * * @see retrieveThreadChannelById */ -@DeprecatedInBcCore @Deprecated("Replaced by retrieveThreadChannelByIdOrNull") @Suppress("deprecated") suspend fun Guild.retrieveThreadChannelOrNull(id: Long): ThreadChannel? { diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/InvalidChannelTypeException.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/InvalidChannelTypeException.kt index 5e503b42d..e0390f2a9 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/InvalidChannelTypeException.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/InvalidChannelTypeException.kt @@ -1,11 +1,8 @@ package dev.freya02.botcommands.jda.ktx.retrieve -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore - /** * Exception thrown when retrieving a channel by ID, but the type is incorrect. * * @see retrieveThreadChannelById */ -@DeprecatedInBcCore class InvalidChannelTypeException(message: String) : IllegalArgumentException(message) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/JDA.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/JDA.kt index c3f3a41aa..22dd707b3 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/JDA.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/JDA.kt @@ -1,6 +1,5 @@ package dev.freya02.botcommands.jda.ktx.retrieve -import dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore import dev.freya02.botcommands.jda.ktx.IgnoreForMatch import dev.freya02.botcommands.jda.ktx.coroutines.await import dev.freya02.botcommands.jda.ktx.requests.runIgnoringResponseOrNull @@ -22,7 +21,6 @@ import net.dv8tion.jda.api.requests.ErrorResponse * * @see JDA.retrieveUserById */ -@DeprecatedInBcCore suspend fun JDA.retrieveUserByIdOrNull(userId: String, @IgnoreForMatch useCache: Boolean = true): User? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_USER) { retrieveUserById(userId).useCache(useCache).await() @@ -39,7 +37,6 @@ suspend fun JDA.retrieveUserByIdOrNull(userId: String, @IgnoreForMatch useCache: * * @see JDA.retrieveUserById */ -@DeprecatedInBcCore suspend fun JDA.retrieveUserByIdOrNull(userId: Long, @IgnoreForMatch useCache: Boolean = true): User? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_USER) { retrieveUserById(userId).useCache(useCache).await() @@ -53,7 +50,6 @@ suspend fun JDA.retrieveUserByIdOrNull(userId: Long, @IgnoreForMatch useCache: B * * @see JDA.retrieveSticker */ -@DeprecatedInBcCore suspend fun JDA.retrieveStickerOrNull(sticker: StickerSnowflake): StickerUnion? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_STICKER) { retrieveSticker(sticker).await() @@ -67,7 +63,6 @@ suspend fun JDA.retrieveStickerOrNull(sticker: StickerSnowflake): StickerUnion? * * @see JDA.retrieveEntitlementById */ -@DeprecatedInBcCore suspend fun JDA.retrieveEntitlementByIdOrNull(entitlementId: String): Entitlement? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_ENTITLEMENT) { retrieveEntitlementById(entitlementId).await() @@ -81,7 +76,6 @@ suspend fun JDA.retrieveEntitlementByIdOrNull(entitlementId: String): Entitlemen * * @see JDA.retrieveEntitlementById */ -@DeprecatedInBcCore suspend fun JDA.retrieveEntitlementByIdOrNull(entitlementId: Long): Entitlement? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_ENTITLEMENT) { retrieveEntitlementById(entitlementId).await() @@ -95,7 +89,6 @@ suspend fun JDA.retrieveEntitlementByIdOrNull(entitlementId: Long): Entitlement? * * @see JDA.retrieveWebhookById */ -@DeprecatedInBcCore suspend fun JDA.retrieveWebhookByIdOrNull(webhookId: String): Webhook? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_WEBHOOK) { retrieveWebhookById(webhookId).await() @@ -109,7 +102,6 @@ suspend fun JDA.retrieveWebhookByIdOrNull(webhookId: String): Webhook? { * * @see JDA.retrieveWebhookById */ -@DeprecatedInBcCore suspend fun JDA.retrieveWebhookByIdOrNull(webhookId: Long): Webhook? { return runIgnoringResponseOrNull(ErrorResponse.UNKNOWN_WEBHOOK) { retrieveWebhookById(webhookId).await() diff --git a/BotCommands-jda-ktx/src/test/kotlin/dev/freya02/botcommands/jda/ktx/MigrationSnapshotTest.kt b/BotCommands-jda-ktx/src/test/kotlin/dev/freya02/botcommands/jda/ktx/MigrationSnapshotTest.kt deleted file mode 100644 index 145fc29f0..000000000 --- a/BotCommands-jda-ktx/src/test/kotlin/dev/freya02/botcommands/jda/ktx/MigrationSnapshotTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -package dev.freya02.botcommands.jda.ktx - -import java.util.zip.ZipEntry -import java.util.zip.ZipInputStream -import kotlin.io.path.Path -import kotlin.io.path.readBytes -import kotlin.test.Test -import kotlin.test.fail - -class MigrationSnapshotTest { - - private val kspOutput = Path(System.getenv("KSP_OUTPUT")) - - @Test - fun `Ensure generated migration files are not modified`() { - val diffFiles = mutableSetOf() - - MigrationSnapshotTest::class.java.getResourceAsStream("/ksp_snapshot.zip")!!.use { inputStream -> - ZipInputStream(inputStream).use { zipStream -> - var entry: ZipEntry? = null - while (zipStream.nextEntry.also { entry = it } != null) { - if (entry!!.isDirectory) continue - val frozenBytes = zipStream.readAllBytes() - val generatedBytes = kspOutput.resolve(entry.name).readBytes() - - if (!(frozenBytes contentEquals generatedBytes)) { - diffFiles += entry.name - } - } - } - } - - if (diffFiles.isNotEmpty()) { - fail("Migration files should have not changed:\n${diffFiles.joinToString("\n")}") - } - } -} diff --git a/BotCommands-jda-ktx/src/test/resources/ksp_snapshot.zip b/BotCommands-jda-ktx/src/test/resources/ksp_snapshot.zip deleted file mode 100644 index 4e1d3f59098bbd005ccfcb46657fb7d2a865f89b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16321 zcmb_@1y~(R(l&0v-QC?ixVr_1aDaom1$PPVArRbyy99SgfZ$FD?jGEJvb(w2uzT;f zyZM`Q&dkFzUGH>P*Hle)y-Kp+5a=M^TSyA0?%z)S@dNpIv<8^lFe&}%CGbBkv9xuv z`pYYko?K~e`xjy{|Mg;1b0;%r!@uZ5^rwAH9Dr^BW>(g}=uG#2cQ&+jGP1R{2G|%o z{)Hf>|4tCV&ipTgvH$nNjBFi%e<6|gf0XF#WN!6i*kB+qASRDX<%X7O_<6*o3_GPf~RvlX?qwgWgZS~~5k$=jl_Ah+CTM4bD^C44BPs-dN3hg1%QgGGda zh2`0mHe9L2^1xRnx%X)KvY3xoM}jhay;7dcwR&N~uSXquwW;(1v4sfO0TIoL$EF@? z$nXZ{<4Ioji?^piT{_1rx2c~QFzV=oV$;KAjyrkR{1VP1-d9ycwG-Pnx=DY;y%!BL z4h}}A`F2Yg95wsrY6E!a-c=RT%;R;&PKzxR@XBpdNw8q&->M&oo5;<_**Jch`U z;qc|eO_g{FLYQVjcIM_&Cib}1+>u&B=D?B5A!EBZ&w8>O3vl$#b`c!d&+ULbalfm~ z{U)<`qG{G`f&hbzIjKJ7x0Nh95a4|7xlPI%gIC0PtN4Va5SM9Vj#3@T5;-0<{dV>E z)q;FuXY-7C$D{A_SVaT}Tr#bk`!<`@Bx(t7;2G!Qr$vh<31b)BuVqW`m#!;%7;Vef zNl9TaSm_yvh!ibc=5xsJ z^+&@6ULH1VcTqZ-_xKlZ^Ij}C-p#JcOla~q)lHhorEqVK zbdf}RChXbIfU=Y9at@+ebY}0_RZPXLVNm3YYam14oD7v>$c%9f^J*1jMjozuA*AgK zP~s-{&{Xf;&OtL;X}D3ZH}G`d#yVJ5*By4W7l|@3g9EtQ+G*q}PT_8NNV@o`V!CFC zMVM+YH00R@)15N1`yTl+$^2e+(0J0LLLZi;&;H$r`2;h6}l z`>GZ|!SqphfLu+)p#dz?dPs&|!GfqIpF7&aDV>TTG!W67WeAB>j>GCJO>BgU3^)~RHDf5`fmNU6yL4i{L%VvmF18V*3rZ-mZPu` zGkT`ZIoqlebV~nj{R@xQueOb&`r&WZ&$CDZMDU3*jKws9LU22%>~2PM7qE(Y&c2+Z zx$>=LwqBoOglwn*&BUJr2H}W?I>bS#&G+c&)Ov8nq@XJkJjVl~G-6CxR1BQKaxi_Z3?!x>;)2HHr@VP1=S){yiqwZIXpr)s$2@O++ zdQGbdHi>s6^*F6Z`amE0*(2L@o%%Q0z`@#h5fbEecp%9R<*G!kE)Q)};#tR5tG1bh zXj`-h1yb+}#ZNS7t%a>0KT5)8ZXRq9)*Khf61;=uD9r?~RWc%cklDXiGq2Y2SZq$5 z19x1>^UM@o#z(8FuNF0cb`KjJbeATm|7wCC1JvgoiN75(NevDC3M00t8b+(tizoI>=Fo2qp9S4BJfDS{g53t-FD({(3YRl4C-S4pYsg2_S~ICkX1L%^W+SweYZsEql|4!hj^AYCoMSuqsxb6;OT_381~+iBgWVz zs{e&;%;K12`Fpz{80ejh1OUtJcxYweOCQXsK7q;5%LB#Ts@sBvbY35jU(E&eErp2c zV+;+!@VkEP(Ndfqzs^=pfB3ci6g}H{PW0fzGrHHhR`wf3dgV}Luwx%+kRjxuxO$k4 zC1hk1hJq+L;;PW#?+*ELrDoqyP(|(26ComNW+Nd*_g`coniEna#7<4q%Tp*@yrNo7 zCOuXlgHgfPTNMyi3-l_2)?$()Z|phz(uU+AB5BCo&96?PV2%wd-6^M<@9&GKO2V-s z7IM7BB@c=85LL-R#)Tp+9|{+phh8PB2FJBFlf+a+KOl&s{6TGUx&bpq8PU&8RugGbw?zx{&02;z=O~TF_aS2YE?m^f?!m=`7OG>ur3GX^OQ9EI4BY?PNsRl$ z9t(=zD-?OFteW%Jw1LY_7938ZM@G7O@a>G4VkC_0Vb~pGyfh=H!35cC+bI}v=QMrr zUK!mN1VDcOgT43}H8(u`w1VrvLv@Eq3vr37$gf*yer^y_q{lYCUu|LH!;-}iM~1Pm z7qHC%?{2A`=Fi6Pw(__}WX-5oB4XPv5wClu(r))}X;{%aR;h%ju3Uj zmPme6?nNn>)~KTsh@(n%`|8x!jZB`Mk0+Rjv8*-Kr=@{c(2|JDs)xw$E=FDDj7|Lj zDc3*{uOk{7R4Bqx)uiQ>soxAYbpFR!((a*GJ=Oxp&AdvSU42!W3&LG!z6J<$T(4*; zP~@o#jlw%H19;#|D76d8?>A428a`%#KrMNH7%9%Y5}S;n6?f=BC0s^d;b2XXnkN<$ z{wA`K(ETxd8Lp@Vws}Op$icAPwRZd9W)8>kTfQc=t_7=l>{Roq5(~R%&=8^^->W3Sgo@6)v4qCF z*=}%nLwhg9q662Zw{wXNfF)1e39q95A^R$E16;qLxmQN~7Y8_iP+%Lj`wP}W;jCO8 zrc7|Ayp3)Wbj;~bt;7dpbB$u=#dBDNbDpahaHvY&w+aHa-M~EL{&8u6W4duob15UmvVxYeF<1t#w)}l}YCg&+EGT38~0W z&{$3-FYyf(O5GNe@KUV1aK;9gm?wU{2r5Q<3t1fKoKr)cJiGFZ-~I%=(Q2ov`@?ld zN$KlwBrjUYqJh+VqF_peL0LQ5F*d3J_!Zjs6T$kLbRx#2F6P=a<~q(EaJ);m{e_qv zZ0v19yj<^OS8g{Bn}hVqW~MeXtw}Y(luKb`bt_mRuRb$wXoLb<;dRi08msxZG90Qo zfI-E3Ak$RAOT!AEhab3gEETrAw_fs6=;9?ur{mg?c%8>=*!D-RCr3ZrL>Aa>P&8Tv zU%^P(u#YeJUx~CYsO?;fH8k6v%yI4~Md4j~ZLPTauaCkK8S{sS3)X;qU|f+fDv9}+ z4b%PBc+kc}^1ze8wMjflJleUyjljUVm{$pnCfJR04~&MCjEnr^ZCxv@Eoz*(|D34T zjBR(DKbv(Pc*L$Y{;+!~afz|AK8U?;LsROt0%kkk73)&H$v zN7}{(U}bJBY6h^e0a~fK*#X5}jevGe=C(F}JkGraE8#ksk$sn+E28jjJ4i_iBX@Ub zz5JS@J6~;%>X0Pq@e|hV@fSkC z7zUg!(L*}buH6@frhJ&r=xevl*l@g>%%@S2FWBn6Kb(7PjIGj9BTIJR zuHuJ>M`+f!3?NS=fq#Q{6?Z8qvFLI7^&AT<@rw*cX7A}ci!8EGZ-~q#jP?BYgaJI% zkX8_LsUE?yqiU)h1=xwKK6-fcSm9kY67*vZJapv=IVvBBF;K0b7|#N|jQm z(d88^Z=h-`$=e&OuHre;&E_W|0S(JtWgr^f7j%Zoy3cz zSQ`bIZNcl~+OT+`W>PQj(*td#bALG``EOduA)3(AZE#k0gZxh0)EH&T zTv&=#r)5gxpm`n^ff%U)3e$F}hcR*UV&ADX8LH}(U?GF*X|r9&RLl$7DN5^Ne1|>4 z{suMPh52Qou41IFCShB?wHzv%P%8 z;HlD-G#upBS8%wTx1TviTO+`OPdZYhVl|IT)ZUpfPmMV#fFr2#<#vRXallq;8*Z?I zZN{2|s3gInyRN6|ft{-oa& z);nSvB^4z95S=lV!P@&4GTBjXRT*#HrB~|r{$`35a4i$vRiU}UHvK>Gq zO+EYaMZPxtblDhMWnaEi*4Ny-&dnrZ!{rq?JJx)#LLlkz^w*(omS5v*cl=p2)8^%zZ9fea4%1_4UpV>^$$w ze0V4f?1PT;+ezsHvm{r8Y!Usfjw3Wf78wA0opz&Z;UJD@_;-VaWxO*8hefw2{vR%D zpcZv(Afk3G-b+W#8P_p#oX?gGR+*!#UG_sC5@rlFj^(G-pil^XCW}hDlwQry10-$DnUgBpTP-nld{#W-+r(f?_{vcA zA++g|SU$r~g?WWf(n`=7O7id4p%gtd&fYeX-|o8XsWT;ykTSxVK4AHegE-2}w+n_PGRRW-2JL zv|_1W2{r+r=~adaSUq|qR4>Dud24x>7sU)>bcR{%cljN2ws0DNvj@mupS^Kp^!*PR82}pe~x=Iec=+H$m8uXJ~UMwHM+&(z9xVpKTRJUgTB$w2!e5y zg$vCC#}v+XCVYSYQYA%9p+GK|*90;e?LBi{@Fs8AWlhXSp|EOS+xE6R`c~HIGBK4P zA;Y(9HX><4Xa&_t!LrMhQH14a^b4<}kP_o|7+BT|@71!8n#8S({84uNi;nd%AUHij zJzNf>-&@`lcw#Pqj4LgrmiL}^Y`6`r+7J$l3Surr2C3;r5NH?~^t47LT5f1gv;_HK zT%9LNQ@-$t^gE@V+qody>Pp9(GN6PJQ(xO!15F-gxN}o zt4&LMDZJT|3V@SvFXI~9(`d0)v3)mzCkM1}yrtzmT9{@m8^$sx0f4bGs<=YIg{M+* zoAnT)m>gBqR@*7ktrog3!rAPJwMgmc5uc@L*;{tHTsJ+_tmgu;{X%rV2p9QcKQ)%35QXWbbJ5!6n-_C9`*k$ynF{YmcQMmE<=CCBx73@<)Oh%> zAW9N|0$E?739CBfowC*<3fPagMB-gPO-v{-F*P=TN(;RJ-AD!7K?SUwazhq_kDG_# zR5$uX952wCqGau(PtIOSCHF|;g?gYH43UOSXtdyF=Tz%($+J|Sfu>O#wEJ>I zo1stFTPGQ}yRW($4TGSx6;lruMP=HlDyV{u=6PFCxevD!K`w5{o-=Mv`5nr<%wWB9 zxq9}i(ZofdskdnfHNW>`?bI8N?oa=*LY~O(_PVj4* zp_ERFEXxfUgkGB=Tt9z()h`Ko`r@9fSV>9lI8_Ku+LcD(=@KD2K6UT_aOz&?sAk!fQk?h#TWhvz;0|6x=b?^y;qa5Bjci$0xq&A=?fw z$r-P3yoCs{^`>?HQU|Af8OHHZ>_m~N_N{>f6yHbR-hKN7DrI&1d2d9VCUq;$gm(CV zq$NN6c2^`fw9y8LXuM_Gmn-UqC7hhxe#zY&vBeq=`WST>v6tz^^NQ4In(?DU=>6^o zo46?<#JLs{&bQbni(>0?g{iO@TLE;0K6c;*9{UfIo=A`-08JD=Zok(7T$oJ(wHGSm zE!Jz28+Ie!EWox`{gEkjhKdmwB)SYXQG=d!-#Tpg8Zv}lN^Lg>K;F*QW3nXm_kH<9 zjd^?HRd!$G^Q*>F=b+zb zYzad=e@!g)A-S%yX&^-|jP(AM>2zu7%b*=$2*+8^K@Zy#{W>mYo_wrI`scwTGTD)! z&SRL_YO|UMC=v0ZqB%23;L%7HUPhwl1i&)tgh}C|vHn4~gjhMkKxXl6en0Uz_bTaL zEw|zqdckktao|r9^4_{DmsSSq11I%ksH%G^9aqJWA1b2|QmcG2qFcn}39?9)WAIuv6KBi6!SU;3)xgnrfXf6MWUvj? z+;xI*%EUrmPE$nHIvISIRY|*<%`wU+G|aQgxAg{uFcQj2)M1CR&<}qE2Jm^*dt5Q; zX4^qfiJQQ&xem5uYGzidOgB(Y3mdx_0GtC{oA0Ac=YDD_a)TCF=eLDuTQ?`2Geq8p zzSxk_P6?1*){EOmZ*|w!85&09pK5W>-P(V*Wud^?dR@~q?i1G*v$p4R|M>*TB$-E` zCZQA3%_u~0umWH-{Z1=!jqO+UFK#w9T0a{5C>98a#BUkAjF|9GrN3Qz%tIshEuCtl zUNhIicXp4fnd5?oO@WGMXIkvgG7ki~%kK@kXphu9cx|%Z#d0zPIg5&}=k?xS51)G- zG*l5CAr}vkM`2j#F;b9@ZY9x1p|O?s9UwP2J#I8n*4tzr`L)c?JKE+Q8>6!(Q%f(x8WUZ>tReO^d!e6{<^pOZk=xi?~3&l!s+ZcUQ-ih$WheX-z3 z(tplOgM##IuxAl+M-wh`vnV!jxj#;5_4@82ST^>cZu-XIoB1p&To*zC+2kH^_iIY^ zv6tp*bg(+E^NCgUaq4&nXG)Dj%ciRR!pK#G0;Z>l#FJH#tFKCFC?>bW(F6L@b%;}r zwr5%s)q{h7bYRvC)Ep4F7!A3OmDQ$e+oRCt%F{3Hk}Wj91bwWBUPA$ znB(DIDDIVBZJumswU}b$CA+y{QKbhfdR}w@9%C9Kyfdue7rV;0J{dAdCSM#*PN9`# zIii;wD6riH9Yb2XtToAL#y&MB-!2l#<M??>>^;I~%pUzY7bR=Uq^4nakBB5u zE*j_CC&V;t(xQwyeQ)2f)0yr|UF-4JEN|__hMZPN#TmSn(rOGdg7nNIYY;%Sw)D{Goab%TkEK4fWQ zI&i3B!-~m>gNoiXa0V{@P>^o*eNC}0h-K?DJgpp8;~Yo>xK6;BhO_#*V?LJ7vw~_) zqUGADhLV@*Q^Q-1EY)nBFCm+PypB?E7{66Utal;+QwJ5?(N^4KT0k~eOayIXz~0<= z1zbWMCrK=D;y&QonVG)S&@l1X+1=M}NUytq884md*gQRr@8MURb;qFpd`AZu!v8$` zviB&pfggK#?W1G9w$Q=tg9N1nHTCLo@DxI+PwZ65SXuPs(ys=6Um_;5{rEf=fdK)L z`7MJM16l!{{&{mLaVdP_??w&p6|=arzLuVQxjG@P*5IM(g#t0aInHVGZo))GxBKC4 ztR}Ax|5Mr506Q8r{WX}6N4m<(F8r29 z#OeBa$7xv;YKbFb4$5@tDNv1MFSL8rUc3tyGUU7dywE1waq%r)b{a-SLWi*uJ%mM$ z%zjp2SHa)1ASwl&rslTSbc>C5qnI5)Hl}~oW!%hV;zM87L4?Sl)q1wOi_H4r5Ft^< zQ3c~TzGWm z+wbYsQNxi>tE$iA6z`FzKp$m`06^_KYE-Hd+|9eIfW4k-KR~W?n9NRJVVXUIdXD~{ zIDro89%tMYbTrcZ4rna0h9_zp(#hnxjMZva7~w?WJ&D4PSUHa7#e%4kMWU+RNtPj_ z7lt11;kD$JvBnRvS=y@M%%^*mv>HB>0#xWa-IsmqdOWpYJ&8c$2N|SzjY-8^_01w} z@Woe+{(51DNPRn0_B)U;=>eVP7Lzt2>T4vLYoqgLYH#=npiOZ+(R1Saaj4G9VXtP? z>$5u(&t*e;=%<%+4j-hD$kPa6ac+;51ti43TcslA>;U-w z7WH$3dOvybdmgKO=}ZHekaRHa2br*wr=$ssmRD%0MHw8bT|IvgTB?iE0CF61lhIH+ z$2fcfUs%BU>l36*(hdx@ol{B^zn9V{&jZgIJxMz)aBL(SgdLcq9+DrRR+ z49VoAvHdN;NqYiqAv{lv>w{|1n*zQ}lc4y?k=h_ZG31EB1a7$$dxW@ggNt}v!R^*8 z+^KJQmu{81W(0SEOGh|qtzvi&o>_DjljyZ_&5)P&AopDwM}`b*5Nly>eSA1X&+Y4u zH&nKK?KO;QJ&0tr*L1DMR~U-srHn}hN~#JOAWJKK-nV`5o)c~qfcO@qByP3b*b2r5 zk7Aia%D|~4GM%tJKswc`>6lZbHtMOyE&dF=s~)PzWFiWNNFM&(s&O?`vPgV+7e1C2 zABc`cCMldD5dE!bzyZmsw2zKirjTFyMm)KXhfC`HWTI$Ue<>L8mH!(#8LKV6`U_vY zgb|Y0%a!>V3+NrdWTR>P*-BS^lF}{EN0z12xmzqVrE4)r$ZZe^uA$1Jn zTnt=@i9F_xpge#?$|g#-d~)*W{(l@{@#ckM73J}j)jNm0e z4z#(@qdL*M;U2!T*%~RCalCJexym;#3zgx5n3M}$`Pj*X#W2T z)X$UaX{RON)yC2~zA`dwa(v#q`8G_kIIt)nb2=-k0!hYqBemw{A+aqP=uu>*kmVYLIH}el&d2&;#m3t*F7oHSW9dz!LmB>8T`epo3IXao?u+~md3}bAjpF*g>d+rn zD{XX+ERH(IZ?pnBkL$%@URY;!q%fvawb#6>zS3P8UV?~fB-^)Ob*IE zyc$ARu+lZF>nop;OFAn~I5CK2cWo&>g_L{Cr!^iHw+Y`h#%3D%TtK9rGo7l38RL5= z*7p`3mg#D8CzP9BsT`O!E)g6bS+nPDcq4J4S5QgJ9rt;m|Bbcbg zdoXD8`p;zIe99zxZsX%kQ$DB2*huJ@IYjnM}eYgbXKm3etpCVc0h)Gee{`|zg>u@3bZl)i$c6AzsEv6V`X%ypsypcJee|5{gqUD zXyq*>`>)}Smy++KvgPZ|{kf--^n3>2C104B)UjjsB&ogN2xcCLlLd8t!=^4>8}|yP z_mmGUyyojC+{5+V@Mo<@%2!nh3eb#nU5Vwf1!h(Tg9(Y{WZV(D73Yhjtu?!|E1_}coor3`VOBhQ+fxFHO6yS0lp=#M@(4N)CxNY2xk@B23p2jZ3N z-8C-}ffXK`b|Qn{1`pf z3}HN#=9dk;-<&V;))^`8RVF{fR<^6*;S0#;@=zVy{)7RNFP0Zq6K0TBkoXITN03P)i*du*;L=BqJj)N>b2cQ_584?bQm&oMuywLIZ0qYDS>o;%RdOWg&~ z);?F)PIiU)Lb*D@Mt`)wTag(=Tr_D?CBm8tmcrk5HOn6nPc9wJg#nNLB1UAdDZ%0QfmWT4x0n^!kS8E1CF z4OU>=T#RD?%S)jQ(plU)IOR*u(YX*aiK^B^d(hbFw|LnJY!eM|&tnMBTzDof&I%1- z+oiz)O~}Abie7&1Mn4+*X<8JW$~3lPw`7ZZZ1oE=X+S*na`FG_pz`K&fKwBIi-$saE_L0^w;u%(sr3$np zuDB6n5sjKlts$R~g*d*e=W-{-Vo*j6kgjxC(2w9ZgMxjF(AXaucGsJs8u{jMriMH8 zITa>{{C4f!NJKQlYkK9^F4j|N;rk+ZhRWm3SUqk;RG&AYmB^2fcTwvz7Avd!6;>jO zr>-KInr#KQf|LdLt32$P7UkvleaMiJKl2`ogM-4QitfK)e7p2yX%4(GB8q&>%gBoS zXG`T}=y)sLT6?Z~bga}GD`}}~T!&ju_ znZ_VPzTz)*)`j6;ercZGj&-u)e20))FajqB7Yq9WPNgdx6DDhHHGDgogt%!0ITRf? zj^bPjaojE!Fx>hwn9HyPr?XaFns0|10emvb+x{HS6akTPj8r_!m`;<>%wG%#eh!Y0 zR{HH)KF;hbNM_NPUP5y)HCykyeyvkj(!+9UcYO%hHEWt0DdU*%)ow?3 z>4>iDKfRXa5iI&DfL*hs6~U1pX!_(>o_^UDuV4vTi8xwwm4HoN!LfH8A(IrZ7hGsJkgFS^Cn-Xjzie<2 z>#i$+KGa-8L;#Em+tYl{@-A0-k(zrYv@95@*Q#ZYx?8bD@6x<_vf3nd{d+X0W~pQ+ z=@8xaQBz@(agc802eS0W-fIq&P03tz zXjfXYr>#3S8TrH|%5*WvWv8~v*nvyRQObfx3oQ5Rx2~TrFND5{x+Y@!(y^K`e^(EF=s_WcNsYp8bXQd7e-sE`>{eXRZ=3E?hA|+Usc*Bl}4_R**>nugq||` zdlnkIFY&4#j7x56)im*X$^7kh*%RX=jIlE86f1J%@jU^h_mqf;)Qjb+kPyl~AJu#en`Z)-|< z1^1#=$;assniMoKE5vVK2YV=GvCP!GXuoGl8C7@%e7tIS#BI_tRd+{#v16#8k-1G`nqO3_zg8%`3IgF&(C#bbR`IY_6mvu0&#@1n8md_85)gho@g5cCXj!CnNo6cf#zCG1Gq``0v!DKNrsaL-OPCPT23i7yb{b(w`%ICoBDEcf#ZUBf<~r z(%*4@1d>n5OFwXG{OBGds{eAD{x*`oBmz1f&7&2@)OzdF-`TqBmW!n%Tws5 zOpTw=Y*4=g{e-vi6!s}^;3q8pW0v=SAMu~C2%f?}t;7BaFZ=9w;2$fppH^i*g??H@ z_!Iguo$?za|4&K^pWe&UV!ogEf`Ixv_ws9L-&545Wh_5YLm#*7{&(GfpZq69El;7J z76bf*ZpHl_=zm`t@D%;&#`I703jE(e|M%O}Ptl+5i~d9}C;T1sf8Hg1iurWw<|n2v z>F;1Z-N<>0`!vJ<6L*ySw{ZU@-~SZ(Y2xiCat+PzApdI`?g#RBgr_v^UxT6h$7tej zX7w`@^H-g}CvJYUJ7GHdf9d>BX`Daz)WknTJRa|a0e>OoXIkf1fBZDD^Fv^bU&enR z?N8G@KZgFp`94jV{DdiaWa&Jaw?BsdFe)L7)j>;8|F`6hLvO?AN@24 R2*Kl@@1yUc`&$h5{{T=#9ftq_ diff --git a/jda-ktx-deprecation-processor/build.gradle.kts b/jda-ktx-deprecation-processor/build.gradle.kts deleted file mode 100644 index c5c7bc3cd..000000000 --- a/jda-ktx-deprecation-processor/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - id("repositories-conventions") - id("kotlin-conventions") -} - -dependencies { - implementation(libs.ksp) - implementation(libs.ksp.aa) - - implementation(libs.jspecify) - - implementation(libs.classgraph) - implementation(libs.kotlin.metadata) - runtimeOnly(libs.jda.ktx) -} - -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/java/dev/freya02/botcommands/jda/ktx/deprecation/utils/KaAccessor.java b/jda-ktx-deprecation-processor/src/main/java/dev/freya02/botcommands/jda/ktx/deprecation/utils/KaAccessor.java deleted file mode 100644 index 1dc2bf055..000000000 --- a/jda-ktx-deprecation-processor/src/main/java/dev/freya02/botcommands/jda/ktx/deprecation/utils/KaAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.utils; - -import com.google.devtools.ksp.impl.symbol.kotlin.KSFunctionDeclarationImpl; -import com.google.devtools.ksp.symbol.KSFunctionDeclaration; -import ksp.org.jetbrains.kotlin.analysis.api.symbols.KaFunctionSymbol; -import org.jspecify.annotations.NullMarked; - -@NullMarked -public class KaAccessor { - - public static KaFunctionSymbol getKaFunctionSymbol(KSFunctionDeclaration declaration) { - return ((KSFunctionDeclarationImpl) declaration).getKtFunctionSymbol$kotlin_analysis_api(); - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/CompatSourceFile.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/CompatSourceFile.kt deleted file mode 100644 index 811cecaf1..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/CompatSourceFile.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation - -import com.google.devtools.ksp.symbol.KSFile - -data class CompatSourceFile( - val processedFile: KSFile, - val packageName: String, - val fileName: String, - val content: String, -) diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/FindReplacePairs.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/FindReplacePairs.kt deleted file mode 100644 index 0fdaf9d7a..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/FindReplacePairs.kt +++ /dev/null @@ -1,24 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation - -import com.google.devtools.ksp.containingFile -import com.google.devtools.ksp.symbol.KSAnnotated -import com.google.devtools.ksp.symbol.KSFile - -class FindReplacePairs { - - private val _processedFiles = mutableListOf() - val processedFiles: List get() = _processedFiles - - private val _pairs = sortedMapOf>() - val pairs: Map> get() = _pairs - - fun add(symbol: KSAnnotated, old: String, new: String) { - _processedFiles.add(symbol.containingFile!!) - _pairs.computeIfAbsent(old) { sortedSetOf() }.add(new) - } - - fun add(pair: RewriteFindReplace) { - _processedFiles.add(pair.processedFile) - _pairs.computeIfAbsent(pair.old) { sortedSetOf() }.add(pair.new) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/RewriteFindReplace.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/RewriteFindReplace.kt deleted file mode 100644 index 96e534a58..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/RewriteFindReplace.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation - -import com.google.devtools.ksp.symbol.KSDeclaration -import com.google.devtools.ksp.symbol.KSFile - -data class RewriteFindReplace( - val processedFile: KSFile, - val old: String, - val new: String, -) { - - companion object { - fun from( - declaration: KSDeclaration, - old: String, - new: String, - ) = RewriteFindReplace(declaration.containingFile!!, old, new) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessor.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessor.kt deleted file mode 100644 index 51b7dad9d..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessor.kt +++ /dev/null @@ -1,41 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.aggregate - -import com.google.devtools.ksp.processing.CodeGenerator -import com.google.devtools.ksp.processing.Dependencies -import com.google.devtools.ksp.processing.Resolver -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.symbol.KSAnnotated - -class AggregateMigrationProcessor( - private val codeGenerator: CodeGenerator, -) : SymbolProcessor { - - override fun process(resolver: Resolver): List { - return emptyList() - } - - override fun finish() { - codeGenerator.createNewFile( - Dependencies( - aggregating = true, - sources = emptyArray() - ), - "META-INF/rewrite", - "migrate-to-bc-jda-ktx", - extensionName = "yml" - ).use { outputStream -> - val aggregateRecipe = """ - --- - type: specs.openrewrite.org/v1beta/recipe - name: dev.freya02.MigrateToBcJdaKtx - description: Migrates most jda-ktx and BotCommands-core extensions to BotCommands-jda-ktx, may require further adjustments - recipeList: - - dev.freya02.MigrateFromJdaKtxToBcJdaKtx - - dev.freya02.MigrateFromBcCoreToBcJdaKtx - - """.trimIndent() - - outputStream.write(aggregateRecipe.encodeToByteArray()) - } - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessorProvider.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessorProvider.kt deleted file mode 100644 index 9488b3a78..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/aggregate/AggregateMigrationProcessorProvider.kt +++ /dev/null @@ -1,14 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.aggregate - -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.processing.SymbolProcessorEnvironment -import com.google.devtools.ksp.processing.SymbolProcessorProvider - -class AggregateMigrationProcessorProvider : SymbolProcessorProvider { - - override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { - return AggregateMigrationProcessor( - environment.codeGenerator, - ) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessor.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessor.kt deleted file mode 100644 index 69b778297..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessor.kt +++ /dev/null @@ -1,211 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.bc - -import com.google.devtools.ksp.containingFile -import com.google.devtools.ksp.processing.CodeGenerator -import com.google.devtools.ksp.processing.Dependencies -import com.google.devtools.ksp.processing.Resolver -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.symbol.KSAnnotated -import com.google.devtools.ksp.symbol.KSClassDeclaration -import com.google.devtools.ksp.symbol.KSFile -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import dev.freya02.botcommands.jda.ktx.deprecation.CompatSourceFile -import dev.freya02.botcommands.jda.ktx.deprecation.FindReplacePairs -import dev.freya02.botcommands.jda.ktx.deprecation.render.* -import dev.freya02.botcommands.jda.ktx.deprecation.utils.KaAccessor -import dev.freya02.botcommands.jda.ktx.deprecation.utils.createFindAndReplaceRecipe -import dev.freya02.botcommands.jda.ktx.deprecation.utils.suffixIfNotEmpty -import ksp.org.jetbrains.kotlin.analysis.api.KaExperimentalApi -import ksp.org.jetbrains.kotlin.analysis.api.symbols.KaNamedFunctionSymbol -import kotlin.io.path.Path -import kotlin.io.path.readText - -private const val DEPRECATED_IN_BC_CORE = "dev.freya02.botcommands.jda.ktx.DeprecatedInBcCore" -private const val UTILS_PACKAGE = "io.github.freya022.botcommands.api.core.utils" - -class DeprecationProcessor( - private val codeGenerator: CodeGenerator, -) : SymbolProcessor { - - private val sourceFiles = arrayListOf() - private val findReplacePairs = FindReplacePairs() - - override fun process(resolver: Resolver): List { - // @DeprecatedInBcCore -> Create accessors and find&replace - resolver - .getSymbolsWithAnnotation(DEPRECATED_IN_BC_CORE, inDepth = false) - .groupBy { it.containingFile!! } - .onEach { (containingFile, deprecatedNodes) -> - - val imports = mutableSetOf() - val functionAccessors = mutableListOf() - val typeAliases = mutableListOf() - - context(imports, findReplacePairs) { - deprecatedNodes.forEach { node -> - when (node) { - is KSFunctionDeclaration -> { - functionAccessors += createFunctionAccessor(node) - .lines() - .joinToString(separator = "\n") { it.trimEnd() } - } - - is KSClassDeclaration -> { - typeAliases += createTypeAlias(node) - } - - else -> error("Unhandled node: $node") - } - } - } - - sourceFiles += CompatSourceFile( - containingFile, - UTILS_PACKAGE, - "${containingFile.fileName.removeSuffix(".kt")}Compat", - generateSource(containingFile, imports, typeAliases, functionAccessors) - ) - } - - return emptyList() - } - - override fun finish() { - require(sourceFiles.isNotEmpty()) - sourceFiles.forEach { (processedFile, packageName, fileName, content) -> - codeGenerator.createNewFile( - Dependencies( - aggregating = true, - sources = arrayOf(processedFile) - ), - packageName = packageName, - fileName = fileName - ).use { outputStream -> - outputStream.write(content.encodeToByteArray()) - } - } - - require(findReplacePairs.pairs.isNotEmpty()) - codeGenerator.createNewFile( - Dependencies( - aggregating = true, - sources = findReplacePairs.processedFiles.toTypedArray() - ), - "META-INF/rewrite", - "bc-core-to-bc-jdk-ktx", - extensionName = "yml" - ).use { outputStream -> - val recipe = createFindAndReplaceRecipe( - name = "dev.freya02.MigrateFromBcCoreToBcJdaKtx", - description = "Migrates most BotCommands-core extensions to BotCommands-jda-ktx, may require further adjustments", - pairs = findReplacePairs, - ) - - outputStream.write((recipe + "\n").encodeToByteArray()) - } - } - - private fun generateSource( - containingFile: KSFile, - imports: Set, - classTexts: List, - functionTexts: List, - ): String = buildString { - append(""" - @file:Suppress("unused") - - package $UTILS_PACKAGE - """.trimIndent()) - - appendLine() - appendLine() - - val existingImports = Path(containingFile.filePath).readText().lines() - .filter { it.startsWith("import") } - .filterNot { it.endsWith("DeprecatedInBcCore") } - if (existingImports.isNotEmpty()) { - appendLine(existingImports.joinToString("\n")) - appendLine() - } - if (imports.isNotEmpty()) { - appendLine(imports.joinToString("\n") { "import $it" }) - appendLine() - } - if (classTexts.isNotEmpty()) { - appendLine(classTexts.joinToString("\n\n")) - appendLine() - } - if (functionTexts.isNotEmpty()) { - appendLine(functionTexts.joinToString("\n\n")) - appendLine() - } - }.trimEnd('\n') + '\n' - - @OptIn(KaExperimentalApi::class) - context(imports: MutableSet, findReplacePairs: FindReplacePairs) - private fun createFunctionAccessor(function: KSFunctionDeclaration): String { - val fullOldFunction = "$UTILS_PACKAGE.${function.simpleName.asString()}" - val fullNewFunction = function.qualifiedName!!.asString() - findReplacePairs.add(function, fullOldFunction, fullNewFunction) - - val functionSymbol = KaAccessor.getKaFunctionSymbol(function) as KaNamedFunctionSymbol - - val docs = function.renderDocString() - val annotations = buildList { - if (functionSymbol.contractEffects.isNotEmpty()) { - add("@OptIn(ExperimentalContracts::class)") - } - function.annotations.filterNot { it.shortName.asString() == "DeprecatedInBcCore" }.forEach { annotation -> - add(annotation.render()) - } - }.joinToString(separator = "\n") - val modifiers = function.renderModifiers().suffixIfNotEmpty(" ") - val typeParameters = function.renderTypeParameters().suffixIfNotEmpty(" ") - val extensionReceiver = function.renderExtensionReceiver() - val functionName = function.simpleName.asString() - val parameters = function.renderParameters() - val returnType = function.returnType!!.resolve().toString() - val contract = functionSymbol.renderContract() - val delegateExpr = run { - val delegateName = "${function.simpleName.asString()}_" - imports += function.qualifiedName!!.asString() + " as $delegateName" - val arguments = function.parameters.joinToString(", ") { - val paramName = it.name!!.asString() - "$paramName = $paramName" - } - "return $delegateName($arguments)" - } - - return buildString { - appendLine(docs) - if (annotations.isNotEmpty()) appendLine(annotations) - if (annotations.lines().none { it.startsWith("@Deprecated") }) { - appendLine(""" - @Deprecated( - message = "Moved to the BotCommands-jda-ktx module\n" + - "You can find & replace:\n" + - "Find: $fullOldFunction\n" + - "Replace: $fullNewFunction" - ) - """.trimIndent()) - } - appendLine("${modifiers}fun ${typeParameters}${extensionReceiver}${functionName}${parameters}: $returnType {") - if (contract.isNotEmpty()) - append(contract.prependIndent()).append("\n\n") - appendLine(delegateExpr.prependIndent()) - - append("}") - } - } - - context(findReplacePairs: FindReplacePairs) - private fun createTypeAlias(clazz: KSClassDeclaration): String { - val aliasName = clazz.simpleName.asString() - val implFullName = clazz.qualifiedName!!.asString() - val typeArguments = clazz.renderTypeParameters() - - findReplacePairs.add(clazz, "$UTILS_PACKAGE.$aliasName", implFullName) - - return "typealias $aliasName$typeArguments = $implFullName$typeArguments" - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessorProvider.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessorProvider.kt deleted file mode 100644 index 93c765f91..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/bc/DeprecationProcessorProvider.kt +++ /dev/null @@ -1,14 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.bc - -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.processing.SymbolProcessorEnvironment -import com.google.devtools.ksp.processing.SymbolProcessorProvider - -class DeprecationProcessorProvider : SymbolProcessorProvider { - - override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { - return DeprecationProcessor( - environment.codeGenerator - ) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxClassProcessor.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxClassProcessor.kt deleted file mode 100644 index 40646b5fd..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxClassProcessor.kt +++ /dev/null @@ -1,26 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.ktx - -import com.google.devtools.ksp.symbol.KSClassDeclaration -import dev.freya02.botcommands.jda.ktx.deprecation.RewriteFindReplace -import dev.freya02.botcommands.jda.ktx.deprecation.utils.RichKotlinClassMetadata -import kotlin.metadata.jvm.KotlinClassMetadata - -object JdaKtxClassProcessor { - - fun findReplacement(symbol: KSClassDeclaration, metadata: List): RewriteFindReplace { - val ktxFullName = metadata.firstNotNullOfOrNull { metadata -> - val (_, clazz) = metadata - if (clazz !is KotlinClassMetadata.Class) return@firstNotNullOfOrNull null - - val targetSymbolFullName = clazz.kmClass.name.replace('/', '.') - val targetSymbolSimpleName = targetSymbolFullName.dropWhile { !it.isUpperCase() } - if (symbol.simpleName.asString() == targetSymbolSimpleName) { - targetSymbolFullName - } else { - null - } - } ?: error("Could not find jda-ktx metadata for symbol ${symbol.qualifiedName!!.asString()}") - - return RewriteFindReplace.Companion.from(symbol, ktxFullName, symbol.qualifiedName!!.asString()) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxFunctionProcessor.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxFunctionProcessor.kt deleted file mode 100644 index b933b9d9d..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxFunctionProcessor.kt +++ /dev/null @@ -1,40 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.ktx - -import com.google.devtools.ksp.symbol.FileLocation -import com.google.devtools.ksp.symbol.KSClassDeclaration -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import dev.freya02.botcommands.jda.ktx.deprecation.RewriteFindReplace -import dev.freya02.botcommands.jda.ktx.deprecation.utils.RichKotlinClassMetadata -import kotlin.metadata.jvm.KotlinClassMetadata - -object JdaKtxFunctionProcessor { - - fun findReplacement(symbol: KSFunctionDeclaration, metadata: List): RewriteFindReplace { - val functionName = symbol.simpleName.asString() - val ksParentDeclaration = symbol.parentDeclaration - val declaringParentName: String = if (ksParentDeclaration == null) { - // Top level - val kmDeclaringFacades = metadata.filter { metadata -> - val (_, facade) = metadata - if (facade !is KotlinClassMetadata.FileFacade) return@filter false - - facade.kmPackage.functions.any { it.name == functionName } - }.distinctBy { it.packageName } - - if (kmDeclaringFacades.size == 1) { - kmDeclaringFacades[0].packageName - } else if (kmDeclaringFacades.isEmpty()) { - error("Could not find file facade with function '${functionName}' (L${(symbol.location as FileLocation).lineNumber}) from '${symbol.packageName.asString()}.${symbol.containingFile!!.fileName}'") - } else { - error("There was multiple file facades with function '${functionName}' (L${(symbol.location as FileLocation).lineNumber}) from '${symbol.packageName.asString()}.${symbol.containingFile!!.fileName}': ${kmDeclaringFacades.joinToString { it.packageName }}") - } - } else if (ksParentDeclaration is KSClassDeclaration) { - // Member - error("jda-ktx doesn't have member functions to specifically replace, annotate the class instead") - } else { - error("Unexpected parent declaration: $ksParentDeclaration") - } - - return RewriteFindReplace.Companion.from(symbol, "${declaringParentName}.${functionName}", symbol.qualifiedName!!.asString()) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessor.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessor.kt deleted file mode 100644 index d87ce8817..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessor.kt +++ /dev/null @@ -1,111 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.ktx - -import com.google.devtools.ksp.processing.* -import com.google.devtools.ksp.symbol.KSAnnotated -import com.google.devtools.ksp.symbol.KSClassDeclaration -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import dev.freya02.botcommands.jda.ktx.deprecation.FindReplacePairs -import dev.freya02.botcommands.jda.ktx.deprecation.utils.RichKotlinClassMetadata -import dev.freya02.botcommands.jda.ktx.deprecation.utils.createFindAndReplaceRecipe -import io.github.classgraph.ClassGraph -import kotlin.metadata.jvm.KotlinClassMetadata -import kotlin.metadata.jvm.Metadata - -private const val REPLACE_JDA_KTX = "dev.freya02.botcommands.jda.ktx.ReplaceJdaKtx" - -class JdaKtxMigrationProcessor( - private val logger: KSPLogger, - private val codeGenerator: CodeGenerator, -) : SymbolProcessor { - - private val findReplacePairs = FindReplacePairs() - - @Suppress("UNCHECKED_CAST") - override fun process(resolver: Resolver): List { - // @ReplaceJdaKtx -> Create find&replace, no accessor as we don't have the sources - val symbols = resolver.getSymbolsWithAnnotation(REPLACE_JDA_KTX, inDepth = false).toList() - if (symbols.isEmpty()) return emptyList() - - val metadata = context(logger) { loadMetadata() } - - for (symbol in symbols) { - val annotation = symbol.annotations.first { it.shortName.asString() == "ReplaceJdaKtx" } - val forcedPkg = annotation.arguments.first { it.name?.asString() == "pkg" }.value as String - - when (symbol) { - is KSClassDeclaration -> { - if (forcedPkg.isNotBlank()) { - findReplacePairs.add(symbol, forcedPkg + "." + symbol.simpleName.asString(), symbol.qualifiedName!!.asString()) - } else { - findReplacePairs.add(JdaKtxClassProcessor.findReplacement(symbol, metadata)) - } - } - is KSFunctionDeclaration -> { - require(symbol.parentDeclaration == null) { "Only top-level functions are supported" } - if (forcedPkg.isNotBlank()) { - findReplacePairs.add(symbol, forcedPkg + "." + symbol.simpleName.asString(), symbol.qualifiedName!!.asString()) - } else { - findReplacePairs.add(JdaKtxFunctionProcessor.findReplacement(symbol, metadata)) - } - } - else -> { - logger.warn("Unhandled declaration: $symbol") - } - } - } - - return emptyList() - } - - @Suppress("UNCHECKED_CAST") - private fun loadMetadata(): List { - return ClassGraph() - .acceptPackages("dev.minn.jda.ktx") - .enableAnnotationInfo() - .scan() - .use { scan -> - buildList { - scan.allClasses.forEach { classInfo -> - val metadataAnnotation = classInfo.annotationInfo.directOnly().get(Metadata::class.java.name) ?: return@forEach - val values = metadataAnnotation.getParameterValues(true) - - val metadata = KotlinClassMetadata.readStrict( - Metadata( - kind = values.getValue("k") as Int, - metadataVersion = values.getValue("mv") as IntArray, - data1 = values.getValue("d1") as Array, - data2 = values.getValue("d2") as Array, - extraString = values.getValue("xs") as String, - packageName = values.getValue("pn") as String, - extraInt = values.getValue("xi") as Int - ) - ) - if (metadata !is KotlinClassMetadata.Class && metadata !is KotlinClassMetadata.FileFacade) return@forEach - - add(RichKotlinClassMetadata(classInfo.packageName, metadata)) - } - } - } - } - - override fun finish() { - require(findReplacePairs.pairs.isNotEmpty()) - codeGenerator.createNewFile( - Dependencies( - aggregating = true, - sources = findReplacePairs.processedFiles.toTypedArray() - ), - "META-INF/rewrite", - "jda-ktx-to-bc-jdk-ktx", - extensionName = "yml" - ).use { outputStream -> - val ktxRecipe = createFindAndReplaceRecipe( - name = "dev.freya02.MigrateFromJdaKtxToBcJdaKtx", - description = "Migrates most jda-ktx extensions to BotCommands-jda-ktx, may require further adjustments", - pairs = findReplacePairs, - ) - - outputStream.write((ktxRecipe + "\n").encodeToByteArray()) - } - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessorProvider.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessorProvider.kt deleted file mode 100644 index e81660df7..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/processor/ktx/JdaKtxMigrationProcessorProvider.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.processor.ktx - -import com.google.devtools.ksp.processing.SymbolProcessor -import com.google.devtools.ksp.processing.SymbolProcessorEnvironment -import com.google.devtools.ksp.processing.SymbolProcessorProvider - -class JdaKtxMigrationProcessorProvider : SymbolProcessorProvider { - - override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { - return JdaKtxMigrationProcessor( - environment.logger, - environment.codeGenerator - ) - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/render/KtRenderers.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/render/KtRenderers.kt deleted file mode 100644 index cf654961d..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/render/KtRenderers.kt +++ /dev/null @@ -1,104 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.render - -import com.google.devtools.ksp.isDefault -import com.google.devtools.ksp.symbol.* -import dev.freya02.botcommands.jda.ktx.deprecation.utils.ifNotEmpty -import ksp.org.jetbrains.kotlin.analysis.api.KaExperimentalApi -import ksp.org.jetbrains.kotlin.analysis.api.contracts.description.KaContractCallsInPlaceContractEffectDeclaration -import ksp.org.jetbrains.kotlin.analysis.api.symbols.KaNamedFunctionSymbol -import ksp.org.jetbrains.kotlin.analysis.api.symbols.KaVariableSymbol - -fun KSDeclaration.renderDocString(): String { - val docString = docString ?: return "" - return buildString { - appendLine("/**") - for (line in docString.lines().drop(1).dropLast(1)) { - appendLine(" *$line") - } - append(" */") - } -} - -fun KSModifierListOwner.renderModifiers(): String { - if (modifiers.isEmpty()) return "" - - return modifiers.joinToString { it.name.lowercase().removePrefix("java_") } -} - -fun KSFunctionDeclaration.renderExtensionReceiver(): String { - val extensionReceiver = extensionReceiver - if (extensionReceiver == null) return "" - - return buildString { - append(extensionReceiver.resolve().toNestedTypeString()) - append(".") - } -} - -fun KSFunctionDeclaration.renderParameters(): String = buildString { - append("(") - append(parameters.joinToString(separator = ", ") { parameter -> - val modifiers = buildString { - if (parameter.isVararg) append("vararg ") - if (parameter.isNoInline) append("noinline ") - if (parameter.isCrossInline) append("crossinline ") - } - - "$modifiers${parameter.name!!.asString()}: ${parameter.type.resolve()}" - }) - append(")") -} - -@OptIn(KaExperimentalApi::class) -fun KaNamedFunctionSymbol.renderContract(): String { - if (contractEffects.isEmpty()) return "" - - return buildString { - append("contract {\n") - append(contractEffects.joinToString("\n") { effect -> - when (effect) { - is KaContractCallsInPlaceContractEffectDeclaration -> - "callsInPlace(${(effect.valueParameterReference.symbol as KaVariableSymbol).name.asString()}, InvocationKind.${effect.occurrencesRange})" - - else -> error("Unhandled contract ${effect::class.qualifiedName}") - } - }.prependIndent()) - append("\n}") - } -} - -fun KSDeclaration.renderTypeParameters(): String { - if (typeParameters.isEmpty()) return "" - - return typeParameters.joinToString(prefix = "<", separator = ", ", postfix = ">") { typeParameter -> - buildString { - if (typeParameter.isReified) append("reified ") - append(typeParameter.name.asString()) - // "Any?" bounds are synthetic, remove those as they are the default bound - typeParameter.bounds.filterNot { it.origin == Origin.SYNTHETIC }.toList().ifNotEmpty { bounds -> - append(" : ") - append(bounds.single().resolve().toNestedTypeString()) - } - } - } -} - -fun KSAnnotation.render(): String { - return "@${this.shortName.asString()}(${this.arguments.filterNot { it.isDefault() }.joinToString(", ") { it.name!!.asString() + " = " + getCompileValue(it.value) }})" -} - -private fun getCompileValue(value: Any?): String { - return when (value) { - is List<*> -> value.joinToString(prefix = "[", separator = ", ", postfix = "]") { getCompileValue(it) } - is String -> "\"$value\"" - is KSAnnotation -> value.render().drop(1) // drop @ for nested annotations - is KSValueArgument -> "${value.name!!.asString()} = ${getCompileValue(value.value)}" - is KSClassDeclaration if (value.classKind == ClassKind.ENUM_ENTRY) -> value.toString() - else -> error("Unsupported annotation value $value") - } -} - -fun KSType.toNestedTypeString(): String { - val parent = ((declaration.parentDeclaration as? KSClassDeclaration)?.simpleName?.asString()?.plus(".")) ?: "" - return "$parent${toString()}" -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Collections.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Collections.kt deleted file mode 100644 index 8c98d86a5..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Collections.kt +++ /dev/null @@ -1,9 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.utils - -inline fun , R> T.ifNotEmpty(block: (T) -> R): R? { - return if (isNotEmpty()) { - block(this) - } else { - null - } -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Recipe.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Recipe.kt deleted file mode 100644 index e0c13c869..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Recipe.kt +++ /dev/null @@ -1,31 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.utils - -import dev.freya02.botcommands.jda.ktx.deprecation.FindReplacePairs - -fun createFindAndReplaceRecipe(name: String, description: String, pairs: FindReplacePairs): String { - val header = """ - --- - type: specs.openrewrite.org/v1beta/recipe - name: $name - description: $description - recipeList: - """.trimIndent() - - val recipes = pairs.pairs.entries.joinToString("\n") { (old, replacements) -> - """ - - org.openrewrite.text.FindAndReplace: - find: "import $old" - replace: "${replacements.joinToString("\\n") { "import $it" }}" - - org.openrewrite.text.FindAndReplace: - find: "import ${old.getPackage()}.*" - replace: "${replacements.joinToString("\\n") { "import ${it.getPackage()}.*" }}" - """.trimIndent().prependIndent(" ") - } - - return header + "\n" + recipes -} - -private fun String.getPackage(): String { - // Assume there are no rule with nested classes, so we can just drop the last import component - return substringBeforeLast('.') -} diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/RichKotlinClassMetadata.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/RichKotlinClassMetadata.kt deleted file mode 100644 index f33a1d6dc..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/RichKotlinClassMetadata.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.utils - -import kotlin.metadata.jvm.KotlinClassMetadata - -data class RichKotlinClassMetadata( - val packageName: String, - val metadata: KotlinClassMetadata, -) diff --git a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Strings.kt b/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Strings.kt deleted file mode 100644 index aeb2efd15..000000000 --- a/jda-ktx-deprecation-processor/src/main/kotlin/dev/freya02/botcommands/jda/ktx/deprecation/utils/Strings.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.freya02.botcommands.jda.ktx.deprecation.utils - -fun String.suffixIfNotEmpty(suffix: String): String { - return if (isNotEmpty()) - this + suffix - else - this -} diff --git a/jda-ktx-deprecation-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/jda-ktx-deprecation-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider deleted file mode 100644 index c3690f33c..000000000 --- a/jda-ktx-deprecation-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider +++ /dev/null @@ -1,3 +0,0 @@ -dev.freya02.botcommands.jda.ktx.deprecation.processor.bc.DeprecationProcessorProvider -dev.freya02.botcommands.jda.ktx.deprecation.processor.ktx.JdaKtxMigrationProcessorProvider -dev.freya02.botcommands.jda.ktx.deprecation.processor.aggregate.AggregateMigrationProcessorProvider diff --git a/settings.gradle.kts b/settings.gradle.kts index 79312c75c..5b3026782 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,7 +11,6 @@ include( ":BotCommands-method-accessors:kotlin-reflect", ) include(":BotCommands-jda-ktx") -include(":jda-ktx-deprecation-processor") include(":spring-properties-processor") include(":BotCommands-spring") include( From ec9a1f42251c5f30e15976a4ed6ff3863bcb3048 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:44:40 +0100 Subject: [PATCH 3/7] jda-ktx: Remove deprecated `retrieveThreadChannelOrNull` --- .../botcommands/jda/ktx/retrieve/Guild.kt | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt index f3679c403..b9d561e37 100644 --- a/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt +++ b/BotCommands-jda-ktx/src/main/kotlin/dev/freya02/botcommands/jda/ktx/retrieve/Guild.kt @@ -112,7 +112,7 @@ suspend fun Guild.retrieveVanityInviteOrNull(): VanityInvite? { * * The [RestAction] may throw [InvalidChannelTypeException] if a channel with the ID was found, but isn't a thread. * - * @see retrieveThreadChannelOrNull + * @see retrieveThreadChannelByIdOrNull */ fun Guild.retrieveThreadChannelById(id: Long): CacheRestAction { return jda.deferredRestAction( @@ -137,30 +137,12 @@ fun Guild.retrieveThreadChannelById(id: Long): CacheRestAction { * * The [RestAction] may throw [InvalidChannelTypeException] if a channel with the ID was found, but isn't a thread. * - * @see retrieveThreadChannelOrNull + * @see retrieveThreadChannelByIdOrNull */ fun Guild.retrieveThreadChannelById(id: String): CacheRestAction { return retrieveThreadChannelById(MiscUtil.parseSnowflake(id)) } -/** - * Retrieves a thread by ID. - * - * The cached threads are checked first, and then a request is made. - * - * The returned thread may be null if: - * - It doesn't exist - * - The bot doesn't have access to it - * - The channel isn't a thread - * - * @see retrieveThreadChannelById - */ -@Deprecated("Replaced by retrieveThreadChannelByIdOrNull") -@Suppress("deprecated") -suspend fun Guild.retrieveThreadChannelOrNull(id: Long): ThreadChannel? { - return retrieveThreadChannelByIdOrNull(id) -} - /** * Retrieves a thread by ID. * From bcf62875e89330593ac475198a859ba667e94527 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Fri, 13 Mar 2026 19:48:12 +0100 Subject: [PATCH 4/7] Remove CHANGELOG.md V2 is nowhere near comparable to V3, there is no clear migration path, and features can be read about on the modules themselves or the wiki --- CHANGELOG.md | 381 --------------------------------------------------- 1 file changed, 381 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 10ba9efe1..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,381 +0,0 @@ -# V3 Overview - -While V3 has most major features reworked and improved, this came to a cost; -in particular, some parts of the API are now built toward Kotlin users. -It is not sure how the API may be adapted to fit Java users more. - -While some features that require configuration using a DSL appeal more to Kotlin users, -they should still be usable by Java users. - -Fortunately, annotation-driven features that already existed can still be used with no problem, both in Java and Kotlin. - -You can also refer to the [examples](BotCommands-core/src/examples) and the [wiki](https://bc.freya02.dev/3.X) -to have an idea on how V3 is supposed to be used. - -## Base package change -To better align with the Maven coordinates, the base package has changed from `com.freya02` to `io.github.freya022`. - -Fixing this should be as simple as using Find & Replace. - -## Kotlin support -All commands and handlers support coroutines (except service factories) and default parameters. - -Each feature has its own `CoroutineScope`, configurable in `BCoroutineScopesConfigBuilder` - -## New dependency injection -In V2, you had to register your resolvers, instances, instance suppliers... using `ExtensionsBuilder`, which enabled you to use constructor and field injection. - -In V3, you no longer need to manually manage your instances manually, a basic DI framework can manage all your services, commands, handlers, resolvers... as long as you annotated them with their appropriate annotations.
-You then simply put a parameter in your constructor/method to receive the requested service type. - -`@BService`, `@Command` and `@Resolver` are the annotations you will need the most. - -Spring IoC is also supported. - -### Services and factories -`@BService` can be used to declare classes as services, or, when used on a method, serves as a factory for the return type.
-As always, if they are on your search path, then they will be instantiated when building the framework, -and available to other classes. - -These services can all have a name, in case you want multiple services of the same type, but want to differentiate them. - -#### Primary providers -When requesting a service, only one service must correspond to the given type/name. - -If multiple service providers exist, only one must be usable, or, only one must be marked primary (using `@Primary`). - -**Note:** Service factories are prioritized over annotated classes. - -**Kotlin note:** Service factories can be top-level functions. - -### Conditional services -#### Interfaced conditions -`@ConditionalService` can be used when you want your service/command/resolver... to be created under certain conditions.
-The annotation will only let the service be created if all the specified check interfaces passes. - -#### Annotation conditions -`@Condition` is a meta-annotation that can be used on an annotation you create, -which enables this annotation to represent a custom condition for service creation. - -You can also specify if failure of these annotations throws an exception. - -[//]: # (An example can be found [here](wiki/src/main/kotlin/io/github/freya022/wiki/switches/wiki/WikiLanguage.kt).) - -### Interfaced services -You can find the `@InterfacedService` annotations on some interfaces of the framework, such as `SettingsProvider` or `IHelpCommand`.
-This annotation indicates that this interface can be implemented, but needs to be registered as a service.
-This is useful for when the framework needs an instance of the interface, without knowing what the implementation is.
-For example, if you want to override the help command, you will need to make an implementation for `IHelpCommand`. - -Most interfaces that were configurable in `CommandsBuilder` were replaced by interfaced services, -such as command/component filters, `SettingsProvider`, `ExceptionHandler`, `AutocompleteTransformer`, etc... - -An example can be found [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/text/HelpCommand.kt). - -## Annotated command changes -Annotated text and slash commands suffered from several issues, -due to the data either being applied to the wrong part of the command, -or no data being applicable on a part of a command (such as subcommand group descriptions). - -To reduce confusion about which property applies to what, and reduce undefined behaviors, -annotations with distinct scopes were introduced: - -Slash commands: -- (Required) `@JDASlashCommand(name, group, subcommand, description)` -- (Required once, when using subcommands) `@TopLevelSlashCommandData(scope, defaultLocked, nsfw, description)` -- (Optional) `@SlashCommandGroupData(description)` - -Text commands: -- (Required) `@JDATextCommandVariation(path, order, description, usage, example)` -- (Optional) `@TextCommandData(path, aliases, description)`, this must be used alongside `@JDATextCommandVariation`, - `path` is the path this annotation applies to, defaults to the variation's path - -This way ensures that the data is only applied to a specific command, -and does not need to be repeated, or follow specific orders. - -More details [on the PR](https://github.com/freya022/BotCommands/pull/146). - -## New command declarations -Commands can now be declared using a DSL, these works best if you use Kotlin. - -### Declaration DSL -To use the DSL, you can check out `GlobalApplicationCommandProvider`/`GuildApplicationCommandProvider` -and `TextCommandProvider`. - -The DSL can help you provide each parameter explicitly, without the need for annotations, -and also enables more features, such as [option aggregates](#option-aggregates). - -The DSL also enables you to declare commands with code, configure your names, descriptions, choices... everything by code, -so you are not limited to static values with annotations. - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashBan.kt), -see `SlashBanDetailedFront#declareGlobalApplicationCommands`. - -## New option aggregates -Option aggregates are a way to combine multiple options into one object, -the function that combines all the options can be anything, including a constructor. - -### Option aggregates -Normal aggregates can accept any option type (Discord option, custom option or generated option). - -You can still insert options without declaring an aggregate; these options will implicitly have an aggregate created for you. - -**Note:** Option aggregates are only available with DSL declaration (and components and modal handlers by using `@Aggregate`). - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashBan.kt), -see `aggregate` in `SlashBanDetailedFront#declareGlobalApplicationCommands`. - -### Vararg options -Vararg options are a special type of option aggregate, they are essentially an aggregate that generates N options, -and the aggregator just accepts a `List` and returns it as-is, i.e. your parameter accepts a `List`, not a real vararg. - -You can use these with `optionVararg`. - -**Note**: Aggregators can accept `List` parameters, but all the options must be under the same *declared* parameter name, so they can be all put in the list. - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashChoose.kt). - -### Inline class options -Kotlin's inline classes can also be used as options, -you can use `inlineClassOption` to declare one in the DSL, they also automatically work for annotated commands. - -`inlineClassOptionVararg` can also be used for inline classes that accept a varargs. - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashSentence.kt), -with `SlashSentence.SentenceParts`. - -## New rate limiting -A [token bucket](https://en.wikipedia.org/wiki/Token_bucket)-based rate limiting has been added, -while `@Cooldown` still exists, `@RateLimit` now lets you define buckets, with multiple bandwidths, -letting you create custom rate limiting for each of your command/component handler. - -A common example is a spike protected bucket, which, in addition to the normal rate limit, -helps you prevent users from spamming a command in a short period of time, -forcing them to spread out your resource usage. - -Rate limits can be used with: -- `@RateLimit` (for annotated commands) -- `#rateLimit`/`#cooldown` (for DSL commands) -- `#rateLimitReference` (for DSL commands and components) -- A provider, by implementing `RateLimitProvider` and using `RateLimitManager#rateLimit`, - using them is as simple as using `@RateLimitReference` for annotated commands, - or `#rateLimitReference` for DSL commands and components. - -A bucket token can be added back by using your event's `#cancelRateLimit()`, -which effectively cancels the rate limit applied before entering any handler. - -## Improved filters - -In addition to being implemented as services, filters can now be used on specific commands / components. - -These filters can be declared as global filters, but must override the `global` property with `false`, -you can then reference those filters in: -- `@Filter`: Requires all filters to pass, can only be used on commands -- The `filters` property of command DSLs, you can even combine filters using `and` and `or`, -such as `filters += (filter() or filter()) and filter()` - -Component filters must be passed while building the components, and have the same usage as for command DSLs. -Java users can also use the `addFilter` methods. - -## Autocomplete changes -Autocomplete annotations and event have been renamed using `Autocomplete` instead of `Autocompletion`. - -Other than that, `@CompositeKey` has been replaced by `compositeKeys` on `@CacheAutocomplete`. -This lets you configure what Discord options (you can also put the parameter name) must be in the caching key, -even if the option is not being used by the autocomplete handler itself. - -The slash command DSL also let you configure autocomplete by using `SlashCommandOptionBuilder#autocomplete` (or `SlashCommandOptionBuilder#autocompleteReference` for handlers defined by annotation). - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashSentence.kt), -on `SlashSentence#onSentencePartAutocomplete`. - -## Text command changes - -Text commands no longer have a `name`/`group`/`subcommand`, they have a `path` instead, which is an array of string. - -**Note:** Text commands are still limited to three path parts. - -## New built-in help command -The command-specific embed has been revamped, -and has separated descriptions for the command and the variations themselves. - -You can also add per-variant usage and examples, both in annotations and in the DSLs. - -

-Example - -For the [following commands](src/testBot/kotlin/dev/freya02/botcommands/bot/readme/TextBan.kt): - -![Help content example](assets/command_help_embed_example.png) -
- -## Async loading -While V2 had to wait for your entire bot to be loaded, -V3 **requires** you to start the framework before building JDA, -which lets you get your stuff started up before the bot goes fully online. - -Building JDA before the framework will result in an error, I strongly recommend that you use a service which implements `JDAService`. - -You can also refer to [the example JDA service](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/Bot.kt). - -## Enhanced database support -A `Database` service has been added, -helping you get a decent abstraction for transactions and reading result rows with ease. -`BlockingDatabase` is the equivalent for Java users, with the same features. - -### H2 Support -While PostgreSQL is still strongly recommended, H2 is also supported, but requires the PostgreSQL compatibility mode. - -This allows you to run an in-memory database, or have it saved to a file, -see [`ConnectionSupplier`](BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/db/ConnectionSupplier.kt) and [H2 Database connection modes](https://www.h2database.com/html/features.html#connection_modes) for more details. - -### Statement logging -This service helps you create statements that are logged at the class that created the statement. -That way, you can enable traces of some of your classes, without having everything else logged. - -The logged statements are reconstructed from the parametrized SQL, and then filled with the parameters, -giving you an executable query, which can be run in a console. - -See [`Database`](BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/core/db/Database.kt) for more details. - -### Long transaction reporting -Additionally, if `BDatabaseConfig#dumpLongTransactions` is enabled, -the framework will report transactions taking longer than `ConnectionSupplier#maxTransactionDuration`, -and will trigger a coroutine / thread dump. - -**Note:** Coroutine dumps require `kotlinx-coroutines-debug`, see `BDatabaseConfig#dumpLongTransactions` for more details. - -## New components -The `Components` utility class is now a service, which means you can get it either in your constructor, or in your handler. - -Like in V2, your components can be set as being usable only once, -being able to be used by certain users/with permissions/with roles... -They can also be constructed using the builder pattern. - -Kotlin users can configure their components using a DSL, -as well as having the handler, and the timeout handler be optional. - -As these handlers are optional, you can still handle them using coroutines, by using `await` on your component/group. - -**Note:** Components have a default timeout (set in `Components`), which invalidates the button after expiration. -You can disable the timeout if necessary using `noTimeout()`, or if you plan on putting the component in a group. -Kotlin users need to make sure to catch `ComponentCancellationException` when using `await()` on them. - -An example can be found [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashButton.kt). - -## New modals -Just like components, modals are now created using a DSL, while their handlers are still annotated. - -The DSL is very similar to the component's DSL, with your usual `bindTo` and `setTimeout` functions, you can also await on your modals. - -**Note:** Modals also have a default timeout (set in `Modals`), which invalidates the modal after expiration. -You can disable the timeout if necessary using `noTimeout()`. -Kotlin users need to make sure to catch `ModalTimeoutException` when using `await()` on them. - -## New event handler - -`@BEventListener` can now be specified to be run asynchronously (within the parallelism limits of `BCoroutineScopesConfig#eventDispatcherScope`), -they can also have a priority assigned to them, as well as a timeout, used for suspending handlers. - -An example can be found [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/ReadyListener.kt). - -## Suspend resolvers & resolver factories -`ParameterResolver` is now type safe and also supports coroutines. - -### Suspending resolvers -Parameter resolvers in Java can override the usual `resolve` method, while Kotlin users can override the `resolveSuspend` function. This is particularly useful when you need to execute a `RestAction`, so you can await without blocking the thread. - -### Resolver factories -Resolver factories were also added to enable you to give a parameter resolver based on the parameter of the function. - -That way, you can return resolvers based on your own conditions, -for example, given the parameter's annotations or generics. - -*This is how `[App/Text]LocalizationContext` are injected, they use factories of `ICustomResolver`, -and when you put a parameter, they read that parameter for `@LocalizationBundle` and then construct a resolver which gets you the correct localization bundle.* - -### Resolvers (& factories) from service factories -Resolvers can not only be created from classes, but also from service factories (function with `@BService`) -returning an implementation. - -For example, the framework provides `Resolver#enumResolver`, which can help you quickly handle any enumeration, -while also (optionally) letting you transform a value into its displayed string. - -## Enhanced localization API -The API has been improved to allow a more detailed loading mechanism, -as to let you extend the API, such as adding support for new formats (like HOCON), or new file structures: - -| Name | Function | -|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [LocalizationMapProvider](BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/providers/LocalizationMapProvider.java) | Responsible for getting a `LocalizationMap` for a given base name and locale, using a broader locale is allowed.
The provider can merge multiple maps as well as modify the base name.
All providers can be found by using `LocalizationService#getMappingProviders`. | -| [LocalizationMapReader](BotCommands-core/src/main/java/io/github/freya022/botcommands/api/localization/readers/LocalizationMapReader.java) | Responsible for reading a given localization map for a given bundle name (base name + locale).
It is allowed to create any type of `LocalizationTemplate`, but is **not** allowed to use a different name or locale.
All readers can be found by using `LocalizationService#getMappingReaders`. | -| [LocalizationMapTemplate](BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/LocalizationTemplate.kt) | Represents a localization template, i.e., the entire string with parameters in it. | -| [FormattableArgumentFactory](BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/api/localization/arguments/factories/FormattableArgumentFactory.kt) | Responsible for creating `FormattableArgument`s based on an argument found in a template.
All factories can be found by using `LocalizationService#getFormattableArgumentFactories`. | - -The old `Localization` factory is now `LocalizationService`. - -## New in-interaction localization -As briefly explained above, localization has been moved from the framework events, into injectable instances, `[App/Text]LocalizationContext`. - -Naturally, `AppLocalizationContext` can only be used with interactions (application commands, components, modals), while `TextLocalizationContext` can be used in interactions and `MessageReceivedEvent` handlers. - -These parameters must be annotated with `@LocalizationBundle`, as to specify where to take the translations from, -and optionally, with what prefix. - -You can specify as many of them as you'd like, as well as construct them manually using the static methods, -or use `switchBundle` which changes the target bundle and clears the prefix. - -In addition, `#localize[X]orNull` can help you return `null` in case the given localization path does not exist. - -You can find an example [here](BotCommands-core/src/examples/kotlin/io/github/freya022/bot/commands/slash/SlashBan.kt). - -## New pagination - -All paginators were reworked with several improvements, here is a list of the changes: -### Name changes -* `ButtonMenu` -> `ChoiceMenu` -* `InteractiveMenu` -> `NestedPagination` - -### Usage changes -* A `Paginators` service that serves as a pagination factory has to be used, improving discoverability -* Mandatory parameters are no longer behind setters, they are requested by the factory - -### New features -* `ButtonMenu` can now change the button style -* `ButtonMenu` can have its buttons reused -* Added support for Kotlin coroutines and `Duration` - * Some callbacks (like `PageEditor`) cannot use coroutines as they are called by method overridable by Java users -* `NestedPagination` saves the page number before switching - -### Changes -* Most options use default values, such as paginator buttons and timeouts -* Requesting a new page invalidates the replaced page's components, can be disabled -* Paginators expire by default using the same timeout as in `Components` -* Timeout consumers are optional, timeout can be entirely disabled -* Page editors no longer require returning an embed, you can freely edit the message and/or the existing embed - -### Extension changes -* Builders are passed instead of their individual values -* Creating a message from the pagination's state is fully handled by the base class, and decomposed into steps that can be overridden - -## Misc - -### Command / Component filters -Filters now support coroutines and are run right before their target should have been executed. - -### Extension functions -Several top-level and extension functions have been added, see the [`BotCommands-jda-ktx`](BotCommands-jda-ktx) module. - -### Input user parameters -A `InputUser` interface, extending `User`, provides a way for you to get a Member (null if not available) -alongside the non-null User, without retrieving. - -This is particularly useful for commands that work for both `User`s and `Member`s, -but where having a `Member` triggers additional checks, such as in ban commands. - -### Emoji library change -[emoji-java](https://github.com/MinnDevelopment/emoji-java) has been replaced with [JEmoji](https://github.com/felldo/JEmoji), -providing a more up-to-date emoji list, -also allowing dropping `org.json` and fixing issues with emoji indexes, and incorrect fitzpatrick formats. - -[jda-emojis](https://github.com/freya022/jda-emojis) was also added to get `UnicodeEmoji`s directly. From c17685642f97d9df26b16fa3b0f80613f4dbb741 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Sat, 14 Mar 2026 15:48:41 +0100 Subject: [PATCH 5/7] Remove deprecated behavior --- .../message/builder/MessageCommandBuilderImpl.kt | 4 ++-- .../MessageCommandOptionAggregateBuilderImpl.kt | 8 ++------ .../user/builder/UserCommandBuilderImpl.kt | 4 ++-- .../UserCommandOptionAggregateBuilderImpl.kt | 8 ++------ .../SlashCommandOptionAggregateBuilderImpl.kt | 8 ++------ .../builder/TextCommandVariationBuilderImpl.kt | 4 ++-- .../TextCommandOptionAggregateBuilderImpl.kt | 8 ++------ .../options/builder/OptionAggregateBuilderImpl.kt | 15 +-------------- .../internal/options/MethodParameters.kt | 10 +--------- 9 files changed, 16 insertions(+), 53 deletions(-) diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/builder/MessageCommandBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/builder/MessageCommandBuilderImpl.kt index d66e26262..ae9e379d1 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/builder/MessageCommandBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/builder/MessageCommandBuilderImpl.kt @@ -32,9 +32,9 @@ internal class MessageCommandBuilderImpl internal constructor( } override fun constructAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = - MessageCommandOptionAggregateBuilderImpl(context, this, aggregatorParameter, aggregator) + MessageCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) internal fun build(): MessageCommandInfoImpl { return MessageCommandInfoImpl(context, this) } -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/options/builder/MessageCommandOptionAggregateBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/options/builder/MessageCommandOptionAggregateBuilderImpl.kt index 15e4f740b..da408309e 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/options/builder/MessageCommandOptionAggregateBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/message/options/builder/MessageCommandOptionAggregateBuilderImpl.kt @@ -2,16 +2,12 @@ package io.github.freya022.botcommands.internal.commands.application.context.mes import io.github.freya022.botcommands.api.commands.application.ApplicationGeneratedValueSupplier import io.github.freya022.botcommands.api.commands.application.context.message.options.builder.MessageCommandOptionAggregateBuilder -import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationCommandOptionAggregateBuilderImpl import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationGeneratedOptionBuilderImpl import io.github.freya022.botcommands.internal.parameters.AggregatorParameter import kotlin.reflect.KFunction internal class MessageCommandOptionAggregateBuilderImpl internal constructor( - override val context: BContext, - override val declarationSiteHolder: IDeclarationSiteHolder, aggregatorParameter: AggregatorParameter, aggregator: KFunction<*> ) : ApplicationCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator), @@ -29,5 +25,5 @@ internal class MessageCommandOptionAggregateBuilderImpl internal constructor( } override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = - MessageCommandOptionAggregateBuilderImpl(context, declarationSiteHolder, aggregatorParameter, aggregator) -} \ No newline at end of file + MessageCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/builder/UserCommandBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/builder/UserCommandBuilderImpl.kt index 93f4d650e..184bdf54b 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/builder/UserCommandBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/builder/UserCommandBuilderImpl.kt @@ -32,9 +32,9 @@ internal class UserCommandBuilderImpl internal constructor( } override fun constructAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = - UserCommandOptionAggregateBuilderImpl(context, this, aggregatorParameter, aggregator) + UserCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) internal fun build(): UserCommandInfoImpl { return UserCommandInfoImpl(context, this) } -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/options/builder/UserCommandOptionAggregateBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/options/builder/UserCommandOptionAggregateBuilderImpl.kt index 717376cba..e6de31de9 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/options/builder/UserCommandOptionAggregateBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/context/user/options/builder/UserCommandOptionAggregateBuilderImpl.kt @@ -2,16 +2,12 @@ package io.github.freya022.botcommands.internal.commands.application.context.use import io.github.freya022.botcommands.api.commands.application.ApplicationGeneratedValueSupplier import io.github.freya022.botcommands.api.commands.application.context.user.options.builder.UserCommandOptionAggregateBuilder -import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationCommandOptionAggregateBuilderImpl import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationGeneratedOptionBuilderImpl import io.github.freya022.botcommands.internal.parameters.AggregatorParameter import kotlin.reflect.KFunction internal class UserCommandOptionAggregateBuilderImpl internal constructor( - override val context: BContext, - override val declarationSiteHolder: IDeclarationSiteHolder, aggregatorParameter: AggregatorParameter, aggregator: KFunction<*> ) : ApplicationCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator), @@ -29,5 +25,5 @@ internal class UserCommandOptionAggregateBuilderImpl internal constructor( } override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = - UserCommandOptionAggregateBuilderImpl(context, declarationSiteHolder, aggregatorParameter, aggregator) -} \ No newline at end of file + UserCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/slash/options/builder/SlashCommandOptionAggregateBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/slash/options/builder/SlashCommandOptionAggregateBuilderImpl.kt index b2800c05f..5a781fb28 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/slash/options/builder/SlashCommandOptionAggregateBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/slash/options/builder/SlashCommandOptionAggregateBuilderImpl.kt @@ -4,7 +4,6 @@ import io.github.freya022.botcommands.api.commands.application.ApplicationGenera import io.github.freya022.botcommands.api.commands.application.slash.options.builder.SlashCommandOptionAggregateBuilder import io.github.freya022.botcommands.api.commands.application.slash.options.builder.SlashCommandOptionBuilder import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationCommandOptionAggregateBuilderImpl import io.github.freya022.botcommands.internal.commands.application.options.builder.ApplicationGeneratedOptionBuilderImpl import io.github.freya022.botcommands.internal.commands.application.slash.builder.SlashCommandBuilderImpl @@ -12,16 +11,13 @@ import io.github.freya022.botcommands.internal.parameters.AggregatorParameter import kotlin.reflect.KFunction internal class SlashCommandOptionAggregateBuilderImpl internal constructor( - override val context: BContext, + private val context: BContext, private val commandBuilder: SlashCommandBuilderImpl, aggregatorParameter: AggregatorParameter, aggregator: KFunction<*> ) : ApplicationCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator), SlashCommandOptionAggregateBuilder { - override val declarationSiteHolder: IDeclarationSiteHolder - get() = commandBuilder - override fun option(declaredName: String, optionName: String, block: SlashCommandOptionBuilder.() -> Unit) { this += SlashCommandOptionBuilderImpl( context, @@ -55,4 +51,4 @@ internal class SlashCommandOptionAggregateBuilderImpl internal constructor( override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = SlashCommandOptionAggregateBuilderImpl(context, commandBuilder, aggregatorParameter, aggregator) -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/builder/TextCommandVariationBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/builder/TextCommandVariationBuilderImpl.kt index 92428ba05..2aabf4d56 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/builder/TextCommandVariationBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/builder/TextCommandVariationBuilderImpl.kt @@ -30,7 +30,7 @@ internal class TextCommandVariationBuilderImpl internal constructor( private val aggregateContainer = OptionAggregateBuilderContainerMixinImpl(function) { aggregatorParameter, aggregator -> - TextCommandOptionAggregateBuilderImpl(context, this, aggregatorParameter, aggregator) + TextCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) } override val optionAggregateBuilders: Map @@ -99,4 +99,4 @@ internal class TextCommandVariationBuilderImpl internal constructor( internal fun build(info: TextCommandInfoImpl): TextCommandVariationImpl { return TextCommandVariationImpl(context, info, this) } -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/options/builder/TextCommandOptionAggregateBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/options/builder/TextCommandOptionAggregateBuilderImpl.kt index 9cbea35bd..187b70f48 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/options/builder/TextCommandOptionAggregateBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/options/builder/TextCommandOptionAggregateBuilderImpl.kt @@ -3,16 +3,12 @@ package io.github.freya022.botcommands.internal.commands.text.options.builder import io.github.freya022.botcommands.api.commands.text.TextGeneratedValueSupplier import io.github.freya022.botcommands.api.commands.text.options.builder.TextCommandOptionAggregateBuilder import io.github.freya022.botcommands.api.commands.text.options.builder.TextCommandOptionBuilder -import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder import io.github.freya022.botcommands.internal.core.options.builder.OptionAggregateBuilderImpl import io.github.freya022.botcommands.internal.parameters.AggregatorParameter import io.github.freya022.botcommands.internal.utils.throwArgument import kotlin.reflect.KFunction internal class TextCommandOptionAggregateBuilderImpl internal constructor( - override val context: BContext, - override val declarationSiteHolder: IDeclarationSiteHolder, aggregatorParameter: AggregatorParameter, aggregator: KFunction<*> ) : OptionAggregateBuilderImpl(aggregatorParameter, aggregator), @@ -50,5 +46,5 @@ internal class TextCommandOptionAggregateBuilderImpl internal constructor( } override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = - TextCommandOptionAggregateBuilderImpl(context, declarationSiteHolder, aggregatorParameter, aggregator) -} \ No newline at end of file + TextCommandOptionAggregateBuilderImpl(aggregatorParameter, aggregator) +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/options/builder/OptionAggregateBuilderImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/options/builder/OptionAggregateBuilderImpl.kt index 02fe9e938..0b6969953 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/options/builder/OptionAggregateBuilderImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/core/options/builder/OptionAggregateBuilderImpl.kt @@ -1,16 +1,10 @@ package io.github.freya022.botcommands.internal.core.options.builder -import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder -import io.github.freya022.botcommands.api.core.objectLogger import io.github.freya022.botcommands.api.core.options.builder.OptionAggregateBuilder -import io.github.freya022.botcommands.api.core.utils.getSignature import io.github.freya022.botcommands.internal.commands.CommandDSL import io.github.freya022.botcommands.internal.core.options.builder.InternalAggregators.isSpecialAggregator -import io.github.freya022.botcommands.internal.core.service.canCreateWrappedService import io.github.freya022.botcommands.internal.parameters.AggregatorParameter import io.github.freya022.botcommands.internal.utils.ReflectionUtils.reflectReference -import io.github.freya022.botcommands.internal.utils.ReflectionUtils.resolveBestReference import io.github.freya022.botcommands.internal.utils.requireAt import kotlin.reflect.KFunction @@ -41,9 +35,6 @@ internal abstract class OptionAggregateBuilderImpl } } - protected abstract val context: BContext - protected abstract val declarationSiteHolder: IDeclarationSiteHolder - final override fun hasVararg(): Boolean = aggregateContainer.hasVararg() final override fun serviceOption(declaredName: String) { @@ -51,10 +42,6 @@ internal abstract class OptionAggregateBuilderImpl } final override fun customOption(declaredName: String) { - if (context.serviceContainer.canCreateWrappedService(aggregatorParameter.typeCheckingParameter) == null) { - objectLogger().warn { "Using ${this::customOption.resolveBestReference().getSignature(source = false)} **for services** has been deprecated, please use ${this::serviceOption.resolveBestReference().getSignature(source = false)} instead, parameter '$declaredName' of ${declarationSiteHolder.declarationSite}" } - return serviceOption(declaredName) - } this += CustomOptionBuilderImpl(aggregatorParameter.toOptionParameter(aggregator, declaredName)) } @@ -72,4 +59,4 @@ internal abstract class OptionAggregateBuilderImpl internal operator fun plusAssign(optionBuilder: OptionBuilderImpl) { _optionBuilders.computeIfAbsent(optionBuilder.optionParameter.typeCheckingParameterName) { arrayListOf() }.add(optionBuilder) } -} \ No newline at end of file +} diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/options/MethodParameters.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/options/MethodParameters.kt index d0383068a..8628e8083 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/options/MethodParameters.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/options/MethodParameters.kt @@ -1,7 +1,5 @@ package io.github.freya022.botcommands.internal.options -import io.github.freya022.botcommands.api.core.BContext -import io.github.freya022.botcommands.api.core.IDeclarationSiteHolder import io.github.freya022.botcommands.api.core.options.annotations.Aggregate import io.github.freya022.botcommands.api.core.options.builder.OptionAggregateBuilder import io.github.freya022.botcommands.api.core.utils.hasAnnotationRecursive @@ -15,7 +13,6 @@ import io.github.freya022.botcommands.internal.utils.ReflectionUtils.function import io.github.freya022.botcommands.internal.utils.ReflectionUtils.nonInstanceParameters import io.github.freya022.botcommands.internal.utils.findDeclarationName import io.github.freya022.botcommands.internal.utils.throwArgument -import io.github.freya022.botcommands.internal.utils.throwInternal import kotlin.reflect.KFunction import kotlin.reflect.KParameter import kotlin.reflect.full.primaryConstructor @@ -25,11 +22,6 @@ private class BasicOptionAggregateBuilderImpl( aggregatorParameter: AggregatorParameter, aggregator: KFunction<*> ) : OptionAggregateBuilderImpl(aggregatorParameter, aggregator) { - override val context: BContext - get() = throwInternal("Internal aggregate builder should not be used outside of the += operator") - - override val declarationSiteHolder: IDeclarationSiteHolder - get() = throwInternal("Internal aggregate builder should not be used outside of the += operator") override fun constructNestedAggregate(aggregatorParameter: AggregatorParameter, aggregator: KFunction<*>) = BasicOptionAggregateBuilderImpl(aggregatorParameter, aggregator) @@ -61,4 +53,4 @@ internal fun Function<*>.transformParameters( this += builderBlock(parameter.function, parameter, declaredName) } } -}.transform(aggregateBlock) \ No newline at end of file +}.transform(aggregateBlock) From 5b5b19680c1ad3257712762225c8864cb5b2b9d5 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Sun, 15 Mar 2026 15:58:46 +0100 Subject: [PATCH 6/7] Remove unused dependencies from version catalog --- gradle/libs.versions.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82c40801d..d8325e10f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,6 @@ jackson = "2.21.1" java-string-similarity = "2.0.0" jda = "6.3.2" jda-emojis = "3.0.0" -jda-ktx = "0.12.0" jemoji = "1.7.5" jetbrains-annotations = "26.0.2" jetbrains-markdown = "0.7.3" @@ -59,7 +58,6 @@ jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module- java-string-similarity = { module = "info.debatty:java-string-similarity", version.ref = "java-string-similarity" } jda = { module = "net.dv8tion:JDA", version.ref = "jda" } jda-emojis = { module = "dev.freya02:jda-emojis", version.ref = "jda-emojis" } -jda-ktx = { module = "club.minnced:jda-ktx", version.ref = "jda-ktx" } jemoji = { module = "net.fellbaum:jemoji", version.ref = "jemoji" } jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" } jetbrains-markdown = { module = "org.jetbrains:markdown", version.ref = "jetbrains-markdown" } @@ -77,7 +75,6 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" } kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } -ksp-aa = { module = "com.google.devtools.ksp:symbol-processing-aa-embeddable", version.ref = "ksp" } logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback-classic" } maven-publish-plugin = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin", version.ref = "maven-publish-plugin" } mockk = { module = "io.mockk:mockk-jvm", version.ref = "mockk" } From 0f1e1b6822a4aa02d633f880b664d0c8b7471fa4 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Sun, 15 Mar 2026 16:03:04 +0100 Subject: [PATCH 7/7] Remove remaining suppressions --- .../internal/commands/text/TextCommandsContextImpl.kt | 4 +--- .../freya022/botcommands/othertests/FunctionTypeTest.kt | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandsContextImpl.kt b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandsContextImpl.kt index b805ae516..3fe118b02 100644 --- a/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandsContextImpl.kt +++ b/BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandsContextImpl.kt @@ -1,5 +1,3 @@ -@file:Suppress("removal") - package io.github.freya022.botcommands.internal.commands.text import io.github.freya022.botcommands.api.commands.text.HelpBuilderConsumer @@ -97,4 +95,4 @@ internal class TextCommandsContextImpl internal constructor( val command = findTextCommand(words) ?: return emptyList() return command.subcommands.values } -} \ No newline at end of file +} diff --git a/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/othertests/FunctionTypeTest.kt b/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/othertests/FunctionTypeTest.kt index f419b29b7..514441a3c 100644 --- a/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/othertests/FunctionTypeTest.kt +++ b/BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/othertests/FunctionTypeTest.kt @@ -1,5 +1,3 @@ -@file:Suppress("OVERRIDE_DEPRECATION", "DEPRECATION") - package io.github.freya022.botcommands.othertests import io.github.freya022.botcommands.api.components.ComponentInteractionFilter @@ -93,4 +91,3 @@ object FunctionTypeTest { } } } -