Tic
Tic
KKord
Created by Tic on 9/18/2024 in #help
Check if embed is removed by user
Hello How can I know if an embed has been removed by the user?
9 replies
KKord
Created by Tic on 8/13/2024 in #help
Check if embed, actionRow etc. has been modified
Hello With the InteractionResponseModifyBuilder, we can define actionRow, embeds etc. However, I would like to avoid to send the same content to the API (to reduce network interaction) Need: So if my message had 2 embeds and 2 actionRows, but only the actionRows are modified since the last rendering, the request must send only the update about actionRows and not Embeds. So naively, I thought to verify with equals the old and new actionRows built, but that not works. For example
println(EmbedBuilder() == EmbedBuilder()) // false
println(EmbedBuilder().apply { title = "Hello" } == EmbedBuilder().apply { title = "Hello" }) // false
println(EmbedBuilder() == EmbedBuilder()) // false
println(EmbedBuilder().apply { title = "Hello" } == EmbedBuilder().apply { title = "Hello" }) // false
have you a better solution to do that?
82 replies
KKord
Created by Tic on 7/18/2024 in #help
Publish multiplatform library (not Discord bot)
Hello This is the list of supported platform of my lib:
iosX64()
iosArm64()
iosSimulatorArm64()
tvosX64()
tvosArm64()
tvosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosX64()
watchosSimulatorArm64()
linuxX64()
linuxArm64()
macosX64()
macosArm64()
mingwX64()
jvm {
}

js {
jsAndWasmSharedConfigurationTarget()
}
wasmJs {
jsAndWasmSharedConfigurationTarget()
}
iosX64()
iosArm64()
iosSimulatorArm64()
tvosX64()
tvosArm64()
tvosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosX64()
watchosSimulatorArm64()
linuxX64()
linuxArm64()
macosX64()
macosArm64()
mingwX64()
jvm {
}

js {
jsAndWasmSharedConfigurationTarget()
}
wasmJs {
jsAndWasmSharedConfigurationTarget()
}
I'm using the plugin https://github.com/gradle-nexus/publish-plugin to publish my lib in maven central However, when I check the availabled action, I can publish for: JVM JS WasmJS MingwX64 LinuxX64 LinuxArm64 But as you can see, the targets: Macos TvOsSimulatorArm64 TsosX64 WatchosArm32 etc. Are not avaiabled in the commands list. For your lib, how do you publish it with these missing targets? Should I change the plugin used?
30 replies
KKord
Created by Tic on 7/17/2024 in #help
Support of native targets (not Discord bot)
Hello I tried to add the support of native targets (not for my discord bot), so I have: (code in comment) However, I have the following error:
KotlinSourceSet with name 'nativeTest' not found.
KotlinSourceSet with name 'nativeTest' not found.
Do you have an idea why I have this error. That's not appears with the code applied:
when {
isMacOs && isArm64 -> macosArm64("native")
isMacOs && !isArm64 -> macosX64("native")
isLinux && isArm64 -> linuxArm64("native")
isLinux && !isArm64 -> linuxX64("native")
isWindows -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
when {
isMacOs && isArm64 -> macosArm64("native")
isMacOs && !isArm64 -> macosX64("native")
isLinux && isArm64 -> linuxArm64("native")
isLinux && !isArm64 -> linuxX64("native")
isWindows -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
5 replies
KKord
Created by Tic on 7/9/2024 in #help
Avoid to re-render buttons and other things
Hello What's the best solution to avoid, during an interaction, sending to much thing that already rendered and not modified For example, if I have a embed with 2 buttons, but I modified only the embed, I would like to avoid to render button Same thing if that the buttons are modified For the moment, I stored all embedBuilder etc. And try to compare with the new ones to verify the equality but I don't know if it's the best solution with kord
1 replies
KKord
Created by Tic on 6/30/2024 in #help
Multiplatform interface problem
Hello Maybe you already have this type of issue and can help me I have the error:
JavaScript name addComponent_948tyo$ is generated for different inherited members: suspend fun addComponent(component: InteractionComponent): Boolean and suspend fun addComponent(component: InteractionRowComponent): Boolean
JavaScript name addComponent_948tyo$ is generated for different inherited members: suspend fun addComponent(component: InteractionComponent): Boolean and suspend fun addComponent(component: InteractionRowComponent): Boolean
With my interface:
interface GlobalMessageBuilder: ComponentMessageBuilder, RowComponentMessageBuilder
interface GlobalMessageBuilder: ComponentMessageBuilder, RowComponentMessageBuilder
And ComponentMessageBuilder & RowComponentMessageBuilder are interface that extend
interface MessageBuilder<C: Component<*>> {

suspend fun addComponent(component: C): Boolean

suspend fun addComponents(components: Collection<C>): Boolean

suspend fun removeComponent(id: String): Boolean

suspend fun removeComponents(ids: Collection<String>): Boolean

suspend fun containsComponent(id: String): Boolean

suspend fun sizeComponents(): Int

suspend fun removeComponents()
}
interface MessageBuilder<C: Component<*>> {

suspend fun addComponent(component: C): Boolean

suspend fun addComponents(components: Collection<C>): Boolean

suspend fun removeComponent(id: String): Boolean

suspend fun removeComponents(ids: Collection<String>): Boolean

suspend fun containsComponent(id: String): Boolean

suspend fun sizeComponents(): Int

suspend fun removeComponents()
}
I tried to override the function and put @JsName but it's not allowed on override functions
3 replies
KKord
Created by Tic on 6/9/2024 in #help
Interaction: Valid action without modify interaction message
Hello When a user click on a button in a RowAction, I would like to do something in my program, with no modification to the interaction message. For the moment, I do: interaction.deferPublicMessageUpdate().edit { } with nothing in it. That works but I think that's not the clean solution What's the good practice to do that?
3 replies
KKord
Created by Tic on 6/8/2024 in #help
Event when ephemeral message is deleted by user
Hello All is in title, but, if I need to clean some things in memory when a message is deleted, in public interaction, that's simple, but for ephemral interaction. Is there a event to detect that? Thanks
4 replies
KKord
Created by Tic on 6/7/2024 in #help
Menu & Edit response
Hello I'm using a Menu to select element. When I select one element, I'm using response.edit to add an embed. But I have two problems: - My embed appears but I have the error message "Interaction failed" - How can I remove the previous menu ? (it stay present below the embed)
3 replies
KKord
Created by Tic on 6/7/2024 in #help
Align field in embed
Hello I have 4 categories to put in an embed. For that, I'm using field. However, I would like to inline the first two together, and the last together. Like
| 1. 2. |
| 3. 4. |
| 1. 2. |
| 3. 4. |
I tried to add an empty field after the 2. but the result is weird like:
| 1. 2. 3. |
| 4. 5. |
| 1. 2. 3. |
| 4. 5. |
The last category is move below the empty field
5 replies
KKord
Created by Tic on 6/7/2024 in #help
Interaction option
Hello I'm tried to add an option to a Chat input command, but unable to find how to instantiate the type expected for the option Have you any clue?
9 replies
KKord
Created by Tic on 6/7/2024 in #help
Interaction disable button
Hello How can I disable a button after a click on it?
3 replies
KKord
Created by Tic on 6/7/2024 in #help
Remove old commands
Hello I'm creating a new bot with the same token than my previous one and I would like to delete all registered slash command How can I do that 🤔 ? Thanks
2 replies
KKord
Created by Tic on 10/13/2023 in #help
Error Json parsing
Hello ! I have an error with my bot (check in thread) After this, the robot may stop working.
7 replies
KKord
Created by Tic on 7/31/2023 in #help
Import dev.kord.x:emoji
Hello Where is published the latest version of kord emoji ? in maven central the last version in 0.5.0 but in Github, the last release is 0.6.0
5 replies
KKord
Created by Tic on 4/5/2023 in #help
Store element in current coroutine context
Hello ! I want to store a temporary redis connection in the current coroutine context to use it later / avoid multiple new connections. Previously, I had this code :
public suspend inline fun <T> connect(crossinline body: suspend (RedisCoroutinesCommands<ByteArray, ByteArray>) -> T): T {
contract {
callsInPlace(body, InvocationKind.EXACTLY_ONCE)
}
return connectionManager.poolStateful.acquire {
val newConnection = it.coroutines()
body(newConnection)
}
}
public suspend inline fun <T> connect(crossinline body: suspend (RedisCoroutinesCommands<ByteArray, ByteArray>) -> T): T {
contract {
callsInPlace(body, InvocationKind.EXACTLY_ONCE)
}
return connectionManager.poolStateful.acquire {
val newConnection = it.coroutines()
body(newConnection)
}
}
And my code works. I changed to store the current connection like :
public suspend inline fun <T> connect(crossinline body: suspend (RedisCoroutinesCommands<ByteArray, ByteArray>) -> T): T {
contract {
callsInPlace(body, InvocationKind.EXACTLY_ONCE)
}

val currentContext = currentCoroutineContext()
val connection = currentContext[RedisConnection]
if (connection != null) return body(connection.connection)

return connectionManager.poolStateful.acquire {
val newConnection = it.coroutines()
withContext(currentContext + RedisConnection(newConnection)) {
body(newConnection)
}
}
}
public suspend inline fun <T> connect(crossinline body: suspend (RedisCoroutinesCommands<ByteArray, ByteArray>) -> T): T {
contract {
callsInPlace(body, InvocationKind.EXACTLY_ONCE)
}

val currentContext = currentCoroutineContext()
val connection = currentContext[RedisConnection]
if (connection != null) return body(connection.connection)

return connectionManager.poolStateful.acquire {
val newConnection = it.coroutines()
withContext(currentContext + RedisConnection(newConnection)) {
body(newConnection)
}
}
}
And I have a new error: (This message in thread) How can I use the new current coroutine context with the flow?
2 replies