Kord

K

Kord

Join the community to ask questions about Kord and get answers from other members.

Join

Kord does not recover from UnknownHostException

It seems like Kord doesn't recover from UnknownHostException - at least not fully as the Discord bot appears as offline and does no longer react to application commands until it is restarted. I ran into this issue two times in the past few weeks. The bot is using google dns to resolve hostnames. Stack trace is attached as screenshot since... discord message character limit... Also, here's the project in case you want to look something up: https://github.com/DarkAtra/v-rising-discord-bot...
No description

Removing components from message with edit

I've seen this being done elsewhere, but I'm being dense right now and just can't do it on Kord. Inside a MessageModifyBuilder block, I've tried setting components to null, empty list, I've tried calling components { }, I've tried adding an empty action row in there (actionRow { }). In all cases, I get the following:
{"components":{"0":{"components":{"_errors":[{"code":"BASE_TYPE_REQUIRED","message":"This field is required"}]}}}}
{"components":{"0":{"components":{"_errors":[{"code":"BASE_TYPE_REQUIRED","message":"This field is required"}]}}}}
...

Basic bot isnt... doing anything?

```kt package aster.amo import aster.amo.App.Companion.LOGGER import aster.amo.App.Companion.getMessageCountInGuild...

(Not Kord) Deserialize JSON with unordered fields (Kotlin Serialization)

Hello I have this deserialization function from my custom Serializer: ```kt override fun deserialize(decoder: Decoder): PacketWrapper {...
Solution:
```kotlin @Serializable sealed interface Packet { val data: Data ...

Select Intent

Hello How can I know which Intent I need for my bot? The bot only use Slash command use buttons etc....
Solution:
intents {
enableEvent<AnEventType>()
}
intents {
enableEvent<AnEventType>()
}
...

Bot reccuringly not responding at specific times

For a few months now, our bot has been having issues during Sundays. It begins every Sunday at 04:00 CET and ends every Monday at 04:00 CET. This coincides with a whole 24h Sunday time on BRT timezone (might be relevant due to bot demographics) We have invested a lot of time investigating it together at the Kordex discord(warning, huge thread) ...
No description

java.io.EOFException on dev.kord.gateway.DefaultGateway

Hey! I am getting some spam of errors on Kord, and after a while it seems to just render my application dead and I have to restart it. ```kotlin...

Error after adding kord dependency

After I added kord to my backend project it throws this error: ```kt Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/plugins/contentnegotiation/ContentNegotiation at com.skyrealm.networking.pelican.http.ConnectionBuilder.build$lambda$4(ConnectionBuilder.kt:26) at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)...
Solution:
you're using a different version of ktor to the one kord uses

Get Heartbeat of Gateway

Mostly I need a way to check the connection status to the Discord API for a healthcheck. Is there any way in Kord to easily get this?

Is there a good way to register all commands at once?

I tried literally everything to get getKord().createGlobalApplicationCommands {} to function But unless i wanna create a massive file with every command in there seperately, it wont work....

Adding a file to a message using getResourceAsStream

val imageStream = javaClass.getResourceAsStream("/images/headerLink.png")
?: throw IllegalArgumentException("Image not found: /images/headerLink.png")
val imageStream = javaClass.getResourceAsStream("/images/headerLink.png")
?: throw IllegalArgumentException("Image not found: /images/headerLink.png")
...
Solution:
You can use ChannelProvider { imageStream.toByteReadChannel() }

Embed markdown for headers not working properly

I made an issue report and was told to come to this discord server to discuss this further ```kotlin channel.createEmbed { title = ""...
Solution:
headers do work in embeds
No description

Ephemeral message

Is there any way to create ephemeral message in Kord?
if (!isAdmin) {message.channel.createMessage(content = "You don't have enough permissions!")}
if (!isAdmin) {message.channel.createMessage(content = "You don't have enough permissions!")}
...

Custom status/activity

How to create custom status/activity - without "playing" and the like? ```kotlin client.editPresence { status = PresenceStatus.DoNotDisturb }...
No description

ClassNotFoundException: kotlinx.io.unsafe.UnsafeBufferOperations

I'm getting this error from using Kord in my Spigot plugin (Minecraft): ClassNotFoundException: kotlinx.io.unsafe.UnsafeBufferOperations. I have all the libraries loading, including kotlinx-io-core-jvm which the error is from. Any clues what could be the problem?

Dependency conflicts...

Kord is using ktor 3.0.0 I'm also using com.aallam.openai:openai-client which depends on ktor 2.3.2 How can I get around this?...

Opus stream to wav?

How can I take the incoming opus stream from a voice channel and save it as a wave file? I have the full opus audio sample as a ByteArray, how do I actually convert this to a wav file?...

Commands stop working after running for a longer amount of time

For some reason if the bot is running for a longer amount of time, the slash commands stop working and fail with the following error: ``` dev.kord.rest.request.KtorRequestException: REST request returned an error: 404 Unknown interaction null at dev.kord.rest.request.KtorRequestHandler.handle(KtorRequestHandler.kt:61)...

How do I get the category a channel is in?

How do I get the category a channel is in, if any? I cant find it, I thought maybe its just based on whatever .getPosition() is but that seems like just a random number lol....
Next