Giter Site home page Giter Site logo

kord's Introduction

Kord

Discord Download 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

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):
<repository>
    <id>snapshots-repo</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <releases>
        <enabled>false</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

<dependency>
    <groupId>dev.kord</groupId>
    <artifactId>kord-core</artifactId>
    <version>{version}</version>
</dependency>

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") return@on

        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" -> gateway.stop()
            "!detach" -> 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.

When will you document your code

Yes.

kord's People

Contributors

alexczar avatar allanwang avatar bartarys avatar bosukas avatar distractic avatar drschlaubi avatar en-you avatar hopebaron avatar kimcore avatar ks129 avatar lost-illusi0n avatar lukellmann avatar moire9 avatar mrbarrientosg avatar mrpowergamerbr avatar noahh99 avatar noakpalander avatar noituri avatar nycodeghg avatar potatopresident avatar tmpod avatar warriorzz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.