Skip to content

Jofairden/Discord.Kt

Repository files navigation

Discord.Kt Discord Publish release ktlint

A Discord library written in Kotlin for Kotlin. The purpose of the library is to be easily able to create a Discord bot in Kotlin with minimal amount of code using Kotlin DSL.

Support status

This lib will likely only ever work on a JVM

  • JVM: ✓
  • JS: ❌
  • Native: ❌

How to use

The library is still in early alpha stage. Use at your own discretion.

Repositories

repositories {
    /**
     * Ensure you have at least these repositories
     */
    mavenCentral()
    jcenter()
    maven {
        name = "Github PKG"
        url = uri("https://maven.pkg.github.com/jofairden/discord.kt")
        credentials {
            /**
             * In order to access Github PKG, you need to enter your username and access token with the read:packages grant
             * To create a personal access token, go to: https://github.com/settings/tokens
             */
            username = System.getenv("MAVEN_PKG_GITHUB_ACTOR")
            password = System.getenv("MAVEN_PKG_GITHUB_TOKEN")
        }
    }
}

Dependencies

Gradle

(Bare minumum)

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.3.3")
    /**
     * Add Discord.Kt as a dependency
     */
    implementation("com.jofairden:discord.kt:LATEST_VERSION")
}

Maven

Locate the final package in the packages page on Github and follow the instructions. You still need to add the repository as shown in the gadle section.

Basic example

For current accurate examples, please see the example bot.

Feature set

Current lib features: (list incomplete)

  • Connect with Discord
  • Send messages including embeds
  • Edit messages
  • Remove messages
  • Pin/unpin messages
  • Ban/unban users
  • React to messages
  • Remove reactions
  • Add/delete/modify roles from guild
  • Change users' roles/nickname
  • Add/delete/modify channels
  • Add/delete guild invites
  • Prune members
  • Hook into any discord event (excluding voice events)
  • Change bot details (name, presence etc)

Technical dev task list

List of things completed, and things yet to be done: (the list may not accurately represent the current state of the lib)

  • Connect with Discord & Send heartbeats
  • Handle connection resumption
  • Message Dispatcher
  • Event Dispatcher (high prio)
  • Event hooking (high prio)
  • Sharding (low prio)
  • Rate limiting (low prio)
  • WebSocket failure reporter
  • Required permission checking (high prio)
  • Retrofit services for all resources
  • Storing resources (cache) (high prio) (not final)
  • Model classes for Guild, User, Role and all other associated resources
  • Command module registration
  • Split generic classes into more specific classes (e.g. DiscordChannel -> GuildChannel -> GuildTextChannel etc.)

Libraries

Discord.kt was built with the following libraries: (the listed libraries may not be final)

Library Version License
OkHttp 4.3.0 Apache 2.0
Jackson 2.10.2 Apache 2.0
Retrofit 2.7.1 Apache 2.0
Kotlin-Logging 1.7.7 Apache 2.0
Caffeine 2.8.0 Apache 2.0
Koin 2.0.1 Apache 2.0

How to get in touch

If you would like to receive help with the lib or help develop the lib, it's best to join our Discord server. Discord is similar to IRC chats. To use Discord you will need to register a new account on their website.

License

Apache 2.0 License

Copyright 2020 Daniël Zondervan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.