Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e7493b1
Add BEventManagerConfig
freya022 Jul 14, 2025
7237eed
Use BEventManagerConfig#defaultTimeout
freya022 Jul 14, 2025
8855563
Use BCoroutineScopesConfig#eventManagerScope for JDA events
freya022 Jul 14, 2025
ad2579a
Re-implement jda-ktx's CoroutineEventManager
freya022 Jul 14, 2025
2a3e935
Add CoroutineEventListener#timeout/cancel()
freya022 Jul 14, 2025
aefb133
Specify default timeout in CoroutineEventListener
freya022 Jul 17, 2025
7abd4d3
Port subset and rework some of jda-ktx's extensions
freya022 Jul 17, 2025
17c0b5b
Make BEventManagerConfig#defaultTimeout nullable
freya022 Jul 17, 2025
13fde59
Bring core module extensions to core module
freya022 Jul 17, 2025
e7e7f6e
Add back `SelectOption` and `StringSelectMenu.Builder.option`
freya022 Jul 18, 2025
c352a5d
Add back some `into()` extensions
freya022 Jul 18, 2025
f51bc2f
Move Coroutines.kt to "coroutines" package
freya022 Jul 18, 2025
d148cbb
Add back `content`, `embeds`, `files`, `components` to message builders
freya022 Jul 18, 2025
3af6515
Replace jda-ktx with BotCommands-jda-ktx
freya022 Jul 18, 2025
4ff592b
Cleanup
freya022 Jul 18, 2025
09f93e5
Move core extensions to jda-ktx module
freya022 Jul 19, 2025
9a6a830
Generate deprecated accessors for old core extensions & rewrite.yml w…
freya022 Jul 20, 2025
354fdc5
Move Listeners.kt to kt source set + core package
freya022 Jul 20, 2025
296bd22
Move core extensions to jda-ktx module
freya022 Jul 20, 2025
42dead6
Require at least 1 argument + optional vararg for RestAction helpers
freya022 Jul 20, 2025
9856d5d
Fix star import migration, rename recipe
freya022 Jul 20, 2025
a70c3ad
Separate jda-ktx and BC-core migration recipes
freya022 Jul 23, 2025
0184ba1
Generate recipe which applies both recipes
freya022 Jul 23, 2025
90cfdca
Register CoroutineEventManagerImpl as a IEventManager
freya022 Jul 23, 2025
cfbc499
Remove `@get:JvmSynthetic` from BEventManagerConfig#defaultTimeout
freya022 Jul 23, 2025
d8bc3f1
Remove "Migrating from jda-ktx"
freya022 Jul 23, 2025
8d66502
Move some extensions out of their package
freya022 Jul 23, 2025
90098ea
Allow generic return type in `runCatchingResponse`
freya022 Jul 23, 2025
9e2dfab
Add then BC-core extensions to README.md
freya022 Jul 23, 2025
091fa40
Use variables for readme shields
freya022 Jul 23, 2025
4e278d9
Add missing Duration extensions
freya022 Jul 24, 2025
02a2423
Add test for missing Duration extensions
freya022 Jul 24, 2025
d00bb30
ksp: Extract and expand annotation rendering
freya022 Jul 24, 2025
c1a210c
ksp: Do not override `@Deprecated`, fix deprecation message
freya022 Jul 24, 2025
2e3e45e
Add overloads of `retrieveThreadChannelByIdOrNull`, deprecated `retri…
freya022 Jul 24, 2025
821ba42
Move utilities
freya022 Jul 24, 2025
afbcbdd
Add missing "retrieveOrNull" extensions
freya022 Jul 24, 2025
50093a6
Test missing "useCache" parameters from methods returning CacheRestAc…
freya022 Jul 24, 2025
3bf6e40
Catch exceptions from RestResult transform methods
freya022 Jul 24, 2025
1b4d7ea
Improve RestResult docs
freya022 Jul 24, 2025
61352f1
Update README.md
freya022 Jul 24, 2025
08b146e
Check if event listener timeout is finite only once
freya022 Jul 24, 2025
4ffbab8
Add back original InlineMessage#actionRow
freya022 Jul 24, 2025
32180cf
Add `null` as `name` default of InlineEmbed#footer
freya022 Jul 25, 2025
9ea1cd2
Remove BC-jda-ktx from BC-spring
freya022 Jul 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions BotCommands-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ dependencies {
exclude(module = "opus-java")
exclude(module = "tink")
}
api(libs.jda.ktx) {
exclude(module = "JDA")
}
implementation(projects.botCommandsJdaKtx)

// Classpath scanning
api(libs.classgraph)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.freya022.bot.commands.slash

import dev.freya02.botcommands.jda.ktx.messages.deleteDelayed
import io.github.freya022.bot.commands.ban.BanService
import io.github.freya022.bot.resolvers.localize
import io.github.freya022.bot.switches.KotlinDetailProfile
Expand All @@ -17,7 +18,6 @@ import io.github.freya022.botcommands.api.components.awaitAny
import io.github.freya022.botcommands.api.components.event.ButtonEvent
import io.github.freya022.botcommands.api.core.entities.InputUser
import io.github.freya022.botcommands.api.core.service.annotations.BService
import io.github.freya022.botcommands.api.core.utils.deleteDelayed
import io.github.freya022.botcommands.api.localization.annotations.LocalizationBundle
import io.github.freya022.botcommands.api.localization.context.AppLocalizationContext
import io.github.freya022.botcommands.api.localization.context.editLocalized
Expand Down Expand Up @@ -167,4 +167,4 @@ class SlashBanSimplifiedFront(private val banImpl: SlashBan) : ApplicationComman
@SlashOption(description = "The unit of the delete timeframe", usePredefinedChoices = true) unit: TimeUnit,
@SlashOption(description = "The reason for the ban") reason: String = localizationContext.localize("outputs.defaultReason")
) = banImpl.onSlashBan(event, localizationContext, target, DeleteTimeframe(time, unit), reason)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.freya022.bot.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.interactions.components.row
import dev.minn.jda.ktx.messages.into
import dev.freya02.botcommands.jda.ktx.components.into
import dev.freya02.botcommands.jda.ktx.components.row
import dev.freya02.botcommands.jda.ktx.coroutines.await
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.CommandScope
Expand Down Expand Up @@ -48,4 +48,4 @@ class SlashButton(private val buttons: Buttons) : ApplicationCommand() {
suspend fun onPersistentButtonClick(event: ButtonEvent) {
event.editButton(event.button.asDisabled()).await()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.freya022.bot.commands.slash

import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.bot.switches.KotlinDetailProfile
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.annotations.VarArgs
Expand Down Expand Up @@ -47,4 +47,4 @@ class SlashChooseSimplifiedFront(private val slashChoose: SlashChoose) : Applica
// Notice here how you are limited to 1 description for all your options
@SlashOption(name = "choice", description = "A choice") @VarArgs(10, numRequired = 2) choices: List<String>
) = slashChoose.onSlashChoose(event, choices)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.freya022.bot.commands.slash

import dev.minn.jda.ktx.interactions.components.SelectOption
import dev.minn.jda.ktx.interactions.components.row
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.components.SelectOption
import dev.freya02.botcommands.jda.ktx.components.row
import dev.freya02.botcommands.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.requests.awaitCatching
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand All @@ -15,7 +16,6 @@ import io.github.freya022.botcommands.api.components.builder.timeoutWith
import io.github.freya022.botcommands.api.components.data.GroupTimeoutData
import io.github.freya022.botcommands.api.components.event.ButtonEvent
import io.github.freya022.botcommands.api.components.event.StringSelectEvent
import io.github.freya022.botcommands.api.core.utils.awaitCatching
import io.github.freya022.botcommands.api.localization.interaction.LocalizableInteractionHook
import kotlin.time.Duration.Companion.seconds

Expand Down Expand Up @@ -99,4 +99,4 @@ class SlashDelayedSelectMenu(
.setReplace(true)
.queue()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.freya022.bot.commands.slash

import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand Down Expand Up @@ -34,4 +34,4 @@ class SlashModal(private val modals: Modals) : ApplicationCommand() {
$code```
""".trimIndent(), ephemeral = true).queue()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.freya022.bot.commands.slash

import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.bot.switches.KotlinDetailProfile
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.annotations.VarArgs
Expand Down Expand Up @@ -81,4 +81,4 @@ class SlashSentenceSimplifiedFront(private val slashSentence: SlashSentence) : A
// Notice here how you are limited to 1 description for all your options
@SlashOption(name = "part", description = "A sentence part", autocomplete = sentencePartAutocompleteName) @VarArgs(10, numRequired = 2) parts: SlashSentence.SentenceParts,
) = slashSentence.onSlashSentence(event, parts)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.provider.GlobalApplicationCommandManager
Expand Down Expand Up @@ -29,4 +29,4 @@ class SlashInMemoryRateLimit : ApplicationCommand(), GlobalApplicationCommandPro
rateLimit(rateLimiter)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.bucket4j.distributed.proxy.ProxyManager
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
Expand Down Expand Up @@ -30,4 +30,4 @@ class SlashPersistentRateLimit(private val proxyManager: ProxyManager<String>) :
rateLimit(rateLimiter)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.interactions.components.row
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.components.row
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.durations.after
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand All @@ -11,7 +12,6 @@ import io.github.freya022.botcommands.api.commands.application.slash.annotations
import io.github.freya022.botcommands.api.commands.application.slash.annotations.SlashOption
import io.github.freya022.botcommands.api.components.Buttons
import io.github.freya022.botcommands.api.components.annotations.RequiresComponents
import io.github.freya022.botcommands.api.core.utils.after
import net.dv8tion.jda.api.interactions.components.buttons.Button
import net.dv8tion.jda.api.utils.TimeFormat
import kotlin.time.Duration.Companion.seconds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.durations.after
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
import io.github.freya022.botcommands.api.commands.application.slash.annotations.JDASlashCommand
import io.github.freya022.botcommands.api.components.EntitySelectMenu
import io.github.freya022.botcommands.api.components.SelectMenus
import io.github.freya022.botcommands.api.components.annotations.RequiresComponents
import io.github.freya022.botcommands.api.core.utils.after
import net.dv8tion.jda.api.entities.Role
import net.dv8tion.jda.api.interactions.components.ActionRow
import net.dv8tion.jda.api.interactions.components.selections.EntitySelectMenu.SelectTarget
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.coroutines.await
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.provider.GlobalApplicationCommandManager
import io.github.freya022.botcommands.api.commands.application.provider.GlobalApplicationCommandProvider
Expand Down Expand Up @@ -31,4 +31,4 @@ class SlashSkip : GlobalApplicationCommandProvider {
rateLimit(RateLimiter.createDefault(RateLimitScope.USER, bucketConfiguration.toSupplier(), deleteOnRefill = true))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.into
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.components.into
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand Down Expand Up @@ -31,4 +31,4 @@ class SlashTypeSafeButtons(private val buttons: Buttons) : ApplicationCommand()
suspend fun onTestClick(event: ButtonEvent, @ComponentData argument: String) {
event.reply_("The argument was: $argument", ephemeral = true).await()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package doc.kotlin.examples.commands.slash

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.into
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.components.into
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent
Expand Down Expand Up @@ -32,4 +32,4 @@ class SlashTypeSafeSelectMenus(private val selectMenus: SelectMenus) : Applicati
suspend fun onTestSelect(event: EntitySelectEvent, @ComponentData argument: String) {
event.reply_("The argument was: $argument", ephemeral = true).await()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package doc.kotlin.examples.filters

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.commands.application.ApplicationCommandFilter
import io.github.freya022.botcommands.api.commands.application.ApplicationCommandInfo
import io.github.freya022.botcommands.api.core.service.annotations.BService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package doc.kotlin.examples.filters

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.messages.reply_
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.reply_
import io.github.freya022.botcommands.api.components.ComponentInteractionFilter
import io.github.freya022.botcommands.api.core.BotOwners
import io.github.freya022.botcommands.api.core.service.annotations.BService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package doc.kotlin.examples.filters

import dev.minn.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.coroutines.await
import io.github.freya022.botcommands.api.commands.text.TextCommandFilter
import io.github.freya022.botcommands.api.commands.text.TextCommandVariation
import io.github.freya022.botcommands.api.core.service.annotations.BService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.freya022.botcommands.api.commands.ratelimit.handler

import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.generics.getChannel
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.getChannel
import dev.freya02.botcommands.jda.ktx.requests.awaitCatching
import dev.freya02.botcommands.jda.ktx.requests.runIgnoringResponse
import io.github.bucket4j.ConsumptionProbe
import io.github.freya022.botcommands.api.commands.application.ApplicationCommandInfo
import io.github.freya022.botcommands.api.commands.ratelimit.RateLimitScope
Expand All @@ -10,9 +12,7 @@ import io.github.freya022.botcommands.api.core.BContext
import io.github.freya022.botcommands.api.core.messages.BotCommandsMessages
import io.github.freya022.botcommands.api.core.messages.BotCommandsMessagesFactory
import io.github.freya022.botcommands.api.core.service.getService
import io.github.freya022.botcommands.api.core.utils.awaitCatching
import io.github.freya022.botcommands.api.core.utils.namedDefaultScope
import io.github.freya022.botcommands.api.core.utils.runIgnoringResponse
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel
Expand Down Expand Up @@ -130,4 +130,4 @@ class DefaultRateLimitHandler(
RateLimitScope.CHANNEL -> messages.channelRateLimited(event, deadline)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.freya022.botcommands.api.components.builder

import dev.minn.jda.ktx.util.ref
import io.github.freya022.botcommands.api.commands.annotations.RateLimitReference
import io.github.freya022.botcommands.api.commands.ratelimit.declaration.RateLimitProvider
import io.github.freya022.botcommands.api.components.ComponentInteractionFilter
Expand All @@ -20,7 +19,6 @@ import io.github.freya022.botcommands.api.parameters.resolvers.ComponentParamete
import io.github.freya022.botcommands.internal.utils.annotationRef
import io.github.freya022.botcommands.internal.utils.javaMethodInternal
import io.github.freya022.botcommands.internal.utils.throwArgument
import net.dv8tion.jda.api.entities.User
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent
import java.util.function.Consumer
import javax.annotation.CheckReturnValue
Expand Down Expand Up @@ -149,6 +147,7 @@ interface IEphemeralActionableComponent<T : IEphemeralActionableComponent<T, E>,
* ### Captured entities
* Pay *extra* attention to not capture JDA entities in such handlers
* as [they can stop being updated by JDA](https://jda.wiki/using-jda/troubleshooting/#cannot-get-reference-as-it-has-already-been-garbage-collected).
* You should instead make a variable from the entity's ID, outside the lambda, then capture it.
*
* @param handler The handler to run when the button is clicked
*/
Expand All @@ -161,9 +160,7 @@ interface IEphemeralActionableComponent<T : IEphemeralActionableComponent<T, E>,
* ### Captured entities
* Pay *extra* attention to not capture JDA entities in such handlers
* as [they can stop being updated by JDA](https://jda.wiki/using-jda/troubleshooting/#cannot-get-reference-as-it-has-already-been-garbage-collected).
*
* You can still use [User.ref] and such from JDA-KTX to attenuate this issue,
* even though it will return you an outdated object if the entity cannot be found anymore.
* You should instead make a variable from the entity's ID, outside the lambda, then capture it.
*
* @param handler The handler to run when the button is clicked
*/
Expand Down Expand Up @@ -1037,4 +1034,4 @@ private fun findHandlerName(func: KFunction<*>): String {
return selectMenuAnnotation.getEffectiveName(func)

throwArgument(func, "Could not find ${annotationRef<JDAButtonListener>()} or ${annotationRef<JDASelectMenuListener>()}")
}
}
Loading