Coder Social home page Coder Social logo

ky28059 / diskord Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jessecorbett/diskord

0.0 0.0 0.0 1.89 MB

[Mirror of GitLab] A Kotlin client for Discord with a light wrapper on the REST APIs and a simple to use DSL for basic bots.

Home Page: https://gitlab.com/jesselcorbett/Diskord

License: Other

Kotlin 100.00%

diskord's Introduction

Diskord

Maven Central Discord

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 the Discord server.

How do I import this?

Gradle

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    // Only if gradle >= 5.3
    implementation 'com.jessecorbett:diskord:1.8.1'

    // Valid for all gradle versions
    implementation 'com.jessecorbett:diskord-jvm:1.8.1'
}

Maven

<dependency>
    <groupId>com.jessecorbett</groupId>
    <artifactId>diskord-jvm</artifactId>
    <version>1.8.1</version>
</dependency>

How do I use this?

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.

Ping Pong Example

const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"

suspend fun main() {
    bot(BOT_TOKEN) {
        commands {
            command("ping") {
                reply("pong")
                delete()
            }
        }
    }
}

Echo Example

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()
            }
        }
    }
}

Embed Example

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"
                }
            }
        }
    }
}

Reaction Example

const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"

suspend fun main() {
    bot(BOT_TOKEN) {
        messageCreated {
            if (it.content.contains("diskord")) {
                it.react("๐Ÿ’ฏ")
            }
        }
    }
}

Combined Example

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()
            }            
        }
    }
}

Intents Example

const val BOT_TOKEN = "A-Totally-Real-Discord-Bot-Token"

suspend fun main() {
    bot(BOT_TOKEN, intents = GatewayIntents.ALL) {
        userPresenceUpdated {
            // Presence data is considered "privileged" and not enabled by default.
            //
            // See [https://discord.com/developers/docs/topics/gateway#gateway-intents] for more information.
        }
    }
}

FAQ

  • Does this support voice chat?
    • No, voice chat is not supported at this time. If you need it I recommend checking out JDA or Discord4J
  • 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 unstable exciting version?

Things to do

  • Add more testing
  • Voice support

diskord's People

Contributors

dhuckaby avatar incendium avatar jessecorbett avatar null-dev 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.