Need help with kord?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kordlib
187 Stars 19 Forks MIT License 1.3K Commits 21 Opened issues

Description

Idiomatic Kotlin Wrapper for The Discord API

Services available

!
?

Need anything else?

Contributors list

# 160,264
Flutter
Ada
Racket
Rails
10 commits
# 115,942
Discord
PHP
ecommer...
php-fra...
2 commits
# 23,505
Kotlin
faceboo...
kotlin-...
multi-s...
1 commit
# 607,180
Discord
Kotlin
kotlin-...
kotlin-...
1 commit
# 408,213
Kotlin
HTML
Spring
Spring ...
1 commit
# 89,429
Shell
Kotlin
Discord
ktor
1 commit

Kord

Discord Download Snapshot Github CI status (branch)

Kord is still in an experimental stage, as such we can't guarantee API stability between releases. While we'd love for you to try out our library, we don't recommend you use this in production just yet.

If you have any feedback, we'd love to hear it, hit us up on discord or write up an issue if you have any suggestions!

What is Kord

Kord is a coroutine-based, modularized implementation of the Discord API, written 100% in Kotlin.

Why use Kord

Kord was created as an answer to the frustrations of writing Discord bots with other JVM libraries, which either use thread-blocking code or verbose and scope restrictive reactive systems. We believe an API written from the ground up in Kotlin with coroutines can give you the best of both worlds: The conciseness of imperative code with the concurrency of reactive code.

Aside from coroutines, we also wanted to give the user full access to lower level APIs. Sometimes you have to do some unconventional things, and we want to allow you to do those in a safe and supported way.

Status of Kord

Right now Kord should provide a full mapping of the non-voice API. We're currently working on a testing library for easy bot testing against a semi mocked client as well as our own command system to facilitate more complex bot development.

Documentation

Installation

Replace

{version}
with the latest version number on maven central.

For Snapshots replace

{version}
with
{branch}-SNAPSHOT

e.g:

0.7.x-SNAPSHOT

Download Snapshot

Gradle (groovy)

repositories {
    mavenCentral()
    // Kord Snapshots Repository (Optional):
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }

}

dependencies {
    implementation("dev.kord:kord-core:{version}")
}

Gradle (kotlin)

repositories {
    mavenCentral()
    // Kord Snapshots Repository (Optional):
    maven("https://oss.sonatype.org/content/repositories/snapshots")

}


dependencies {
    implementation("dev.kord:kord-core:{version}")
}

Maven

Kord Snapshots Repository (Optional):
    snapshots-repo
    https://oss.sonatype.org/content/repositories/snapshots
    
        false
    
    
        true
    


    dev.kord
    kord-core
    {version}

Modules

Core

A higher level API, combining

rest
and
gateway
, with additional (optional) caching. Unless you're writing your own abstractions, we'd recommend using this.
suspend fun main() {
    val client = Kord("your bot token")
    val pingPong = ReactionEmoji.Unicode("\uD83C\uDFD3")

client.on<messagecreateevent> {
    if (message.content != "!ping") [email protected]

    val response = message.channel.createMessage("Pong!")
    response.addReaction(pingPong)

    delay(5000)
    message.delete()
    response.delete()
}

client.login()

}

Rest

A low level mapping of Discord's REST API. Requests follow Discord's rate limits.

suspend fun main() {
    val rest = RestClient("your bot token")

rest.channel.createMessage("605212557522763787") {
    content = "Hello Kord!"

    embed {
        color = Color.BLUE
        description = "Hello embed!"
    }
}

}

Gateway

A low level mapping of Discord's Gateway, which maintains the connection and rate limits commands.

suspend fun main() {
    val gateway = DefaultGateway()

gateway.on<messagecreate> {
    println("${message.author.username}: ${message.content}")
    val words = message.content.split(' ')
    when (words.firstOrNull()) {
        "!close" -&gt; gateway.stop()
        "!detach" -&gt; gateway.detach()
    }
}.launchIn(gateway)

gateway.start("your bot token")

}

FAQ

Will you support kotlin multi-platform

We will, there's an issue open to track the features we want/need to make a transition to MPP smooth.

Will you support voice

Yes, please check #101

When will you document your code

Yes.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.