Skip to content

Latest commit

 

History

History
105 lines (82 loc) · 2.62 KB

README.md

File metadata and controls

105 lines (82 loc) · 2.62 KB

Kord Core

Kord core is an implementation of the discord api build on top of the gateway, rest and cache modules. It features a high level representation of Discord's entities and their behaviour in a non-blocking, coroutine focused, event-driven design.

Example usage

suspend fun main() {
    val kord = Kord("your bot token")

    // Flow style
    kord.events
        .filterIsInstance<MessageCreateEvent>()
        .map { it.message }
        .filter { it.author?.isBot == false }
        .filter { it.content == "!ping" }
        .onEach { it.channel.createMessage("pong") }
        .launchIn(kord)

    // Simplified style
    kord.on<MessageCreateEvent> {
        if (message.author?.isBot == true) return@on
        if (message.content == "!ping") message.channel.createMessage("pong")
    }

    kord.login {
        @OptIn(PrivilegedIntent::class)
        intents += Intent.MessageContent
    }
}

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("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-jvm</artifactId>
    <version>{version}</version>
</dependency>