Skip to content

Home

DiscordKt is a Kotlin Discord library, built on top of Kord - a Kotlin Discord API.

dependencies {
    implementation("me.jakejmattson:DiscordKt:0.23.4")
}
dependencies {
    implementation 'me.jakejmattson:DiscordKt:0.23.4'
}
<dependencies>
    <dependency>
        <groupId>me.jakejmattson</groupId>
        <artifactId>DiscordKt</artifactId>
        <version>0.23.4</version>
    </dependency>
</dependencies>

Syntax Samples

Below are some syntax samples for the library.

Startup

fun main(args: Array<String>) {
    val token = "your-bot-token"

    bot(token) {
      prefix { "+" }
    }
}

Commands

fun demo() = commands("Demo") {
    slash("Hello", "A 'Hello World' command.") {
        execute {
            respond("Hello World!")
        }
    }

    slash("Add", "Add two numbers together.") {
        execute(IntegerArg("First"), IntegerArg("Second")) {
            val (first, second) = args
            respond(first + second)
        }
    }
}

Events

fun testListeners() = listeners {
    on<MessageCreateEvent> {
        println(message.content)
    }
}