A Kotlin client for Discord bots with a simple and concise DSL
Built as a lean client using coroutines that gets the intricacies of rate limits, async, and data models out of your way in a clean and easy to use SDK.
Feel free to submit a PR or an Issue and I'll address it ASAP.
Using Diskord? Send me a tweet about it! @JesseLCorbett or drop by our Discord server.
repositories {
mavenCentral()
jcenter() // Necessary for kotlinx.serialization, until it is published in maven central too
}
dependencies {
// Only if gradle >= 5.3
implementation 'com.jessecorbett:diskord:1.5.1'
// Valid for all gradle versions
implementation 'com.jessecorbett:diskord-jvm:1.5.1'
}
<dependency>
<groupId>com.jessecorbett</groupId>
<artifactId>diskord-jvm</artifactId>
<version>1.5.1</version>
</dependency>
Simply instantiate a bot using the bot DSL, such as in the examples below.
Any function in the scope of the DSL will have access to a ClientStore clientStore
to access clients for the bot user.
Additionally, extensions on the bot DSL, like the command DSL, can be done simply by writing extension functions which hook into the bot DSL on instantiation.
You can find more examples here.
You can access the documentation here.
const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"
suspend fun main() {
bot(BOT_TOKEN) {
commands {
command("ping") {
reply("pong")
delete()
}
}
}
}
const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"
suspend fun main() {
bot(BOT_TOKEN) {
commands {
command("echo") {
reply(words.drop(1).joinToString(" "))
delete()
}
}
}
}
const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"
suspend fun main() {
bot(BOT_TOKEN) {
// Defaults to using command prefix `.` if unspecified
commands("!") {
command("embed") {
delete()
reply {
text = "This is an embed"
title = "Embed title"
description = "You can declare all the things here"
}
}
}
}
}
const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"
suspend fun main() {
bot(BOT_TOKEN) {
messageCreated {
if (it.content.contains("diskord")) {
it.react("💯")
}
}
}
}
const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"
suspend fun main() {
bot(BOT_TOKEN) {
messageCreated {
if (it.content.contains("diskord")) {
it.react("💯")
}
}
// Defaults to using command prefix `.`
commands {
command("ping") {
reply("pong")
delete()
}
command("echo") {
reply(words.drop(1).joinToString(" "))
delete()
}
}
}
}
- Does this support voice chat?
- Is this library done?
- It still needs some tests written, but Diskord is actively maintained and API complete, so it should be safe to use
- Can I contact you to ask a question/contribute to the project/report a bug/tell you this is all shit?
- What if I'm hip and cool, and I want to use a newer more
unstableexciting version?- You can use our development versions by using the snapshot repository
- Repository URL https://oss.sonatype.org/content/repositories/snapshots/
- Artifact directory https://gitlab.com/jesselcorbett/diskord/-/packages
- You can use our development versions by using the snapshot repository
- Add more testing
- Voice support